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
package.json: use file extensions for esmodules compatibility #19
Conversation
for esmodules compatibility
Somehow we have 3 different packages with 3 different styles 😆 The "main": "xlsx.js",
"types": "types/index.d.ts", The "main": "./adler32",
"types": "types/index.d.ts", This PR is proposing "main": "./crc32.js",
"types": "./types/index.d.ts", Ideally there'd be one style for the main script and for the types. Ping @josh-hemphill @ntnyq |
Also, since this is top of mind, would it be helpful to also ship an ESM version? For another project, |
Using explicit extensions is necessary for compatibility with ESM and typescript. I personally like avoiding the use of So for libraries, I think just always using |
that's funny 😄 I also tended not to use relative imports, but I was reading the package.json "exports" proposal (https://github.com/jkrems/proposal-pkg-exports/) and it's recommended there, so I've been using
It's specifically talking about the values of the "exports" keys, so maybe it doesn't apply here, but I figure why not. |
The official npm docs has an example with "main": "lib/waza.js"
"main": "",
"types": "index.d.ts", The "standard" approach seems to be "use file extensions" and "don't prepend with @ryanio please try it without the "main": "crc32.js",
"types": "types/index.d.ts", The |
Sounds good, will try and update, should be fine edit: yep it worked for me locally! |
thanks for this wonderful repository! we use it in @ethereumjs/common
we are just upgrading to esmodules support and found these file extensions necessary to get to the types, we'll put a hotfix in place but thought it would be nice to contribute upstream