-
Notifications
You must be signed in to change notification settings - Fork 98
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
Define exports entrypoints using default #169
Conversation
Should be last, per documentation: https://nodejs.org/api/packages.html#conditional-exports
Hmm, how widely is this supported in the ecosystem? Is it possible / safe to have both an (I actually really like this change, thanks for teaching me about it. But I've faced a lot of very unfortunate bundler assumptions over the years that can make it a lot of work to adopt these kind of changes. Also, since this is mainly a browser library bundler support is a bigger concern than runtime support.) |
Aha!
|
Yeah, my understanding is that it ought to work same as it does today, but with CommonJS compatibility. If you're concerned, a more conservative option could be to leave things as they are, and add an additional I couldn't find much about the |
Hmm, I'm not really sure what to do here. On the one hand, if this makes life easier for CommonJS folks, I don't mind it. On the other hand, I have completely removed CommonJS code from my life. The package is ESM, and any compatibility with loading from CommonJS is incidental. I also didn't know the ordering was semantic, which is something supported by all JavaScript runtime, but as far as I know is not a feature of JSON in general. So I don't know if I might be making more work with myself down the line by adding a I guess what I can do is merge and publish this with |
Works for me 👍 |
Published in |
Thanks @lgarron, seems to work great in our CommonJS project now! |
Updates the
package.json
exports
to set default entrypoints usingdefault
instead ofimport
.Reference documentation: https://nodejs.org/api/packages.html#conditional-exports
"import"
limits use to ESM environments. As of Node.js v22 (current LTS), there's now improved support to allow CommonJS to use ESM-only projects like this one.Without these changes, a CommonJS project trying to import this library will encounter the following error:
(This is actually a long-delayed follow-up to #148 (comment), where our project is still CommonJS, but we'd love to be able to upgrade with this new capability in Node.js v22)