-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Typings for the main
and browser
property in package.json
#29128
Comments
If your package has different types in node vs the browser.... have you considered that you really have two separate packages? We assume that a single package has a single API. |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow. |
This is a feature request, not a question, so you should at least re-tag it as "Won't Fix". I am looking at converting my JS package to TypeScript and in my package I'm loading a dependency that has a version for node and a WASM version for the browser. I I like doing it this way because then all my code (which is otherwise the same between node and browser) can live in a single repository and I don't want users of my package to have to know about that dependency or to know that there's a node and a browser version of my package. |
We similarly could use this in our Next.js SDK. Any library built for an isomorphic framework like Next is likely to run into this. Also:
Until the node and browser APIs are identical, I don't think this is a fair criticism. |
Have set the default types to the browser types There is currently no way to do isomorphic types See microsoft/TypeScript#29128
Have set the default types to the browser types There is currently no way to do isomorphic types See microsoft/TypeScript#29128
Have set the default types to the browser types There is currently no way to do isomorphic types See microsoft/TypeScript#29128
I know this is old, but +1 from me. I've written a few universal libraries, and this is the single biggest feature missing from Typescript for me. The For example, I have a universal library that reads and writes files. The node version cannot use the HTML5 So there is a node-specific |
Search Terms
package.json typescript browser main isomorphic multiple typings
Suggestion
I have asked a question on StackOverflow (https://stackoverflow.com/questions/53847688/types-field-in-package-json-for-browser-and-main-field), but I have not gotten any reactions and now I'm wondering if it is at all possible. Hence a feature request.
Use Cases
I have build an isomorphic lib, to be used in node and the browser (HuygensING/xmlio). NPM has a solution for that, using the
main
andbrowser
properties in package.json. But, there is only onetypings
property. How to specify two different typings? One for the browser and one for node?The text was updated successfully, but these errors were encountered: