Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear which base is best for Web based typescript packages #264

Open
ryanbas21 opened this issue Apr 11, 2024 · 2 comments
Open

Unclear which base is best for Web based typescript packages #264

ryanbas21 opened this issue Apr 11, 2024 · 2 comments

Comments

@ryanbas21
Copy link

Hi,

I spent a long time yesterday trying to understand what tsconfig settings one should use for creating a typescript package intended for use on the web. I believe, based on the documentation, Node16 is still the best option since it mostly will work with bundlers.

It would be a nice addition to this repo to have a little more clarity for those creating packages specifically for the web. This could be simply adding text above which config fits this need the best.

Also - Node16 changes how imports need to resolve with extensions which i know is not the most common practice in modern web development, although it seems to be the written standard ( may be wrong on that).

So i guess my issue is, can we either add text to the proper config and note this is best for web based packages as well - or create a base that highlights a config that a web based package can use and publish to npm, to create a modern typescript package intended to be consumed by others.

Thanks!

@orta
Copy link
Member

orta commented Apr 14, 2024

We target runtimes with the bases, and you could very reasonably argue that the web is a runtime but I think doing so would be misleading on our part.

If you're writing code using a bundler, your runtime is that bundler (which is why we have vite support in here for example) but if you're using typescript to change some .ts files to .js files as a <script> then what you really want is a "lowest target browser runtime" tsconfig base and I don't want to commit to recreating something like @babel/preset-env in this repo to do it accurately

@ryanbas21
Copy link
Author

So if i understand the above, really there is no moduleResolution setting needed for a browser based target, its really just setting target to whatever browser your trying to hit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants