-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add support for Node ESM #4038
Add support for Node ESM #4038
Conversation
# Conflicts: # examples/rsp-next-ts/next.config.mjs
…SM-again # Conflicts: # package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert circle ci config.yml changes for approval
Build successful! 🎉 |
Build successful! 🎉 |
## API Changes
unknown top level export { type: 'identifier', name: 'Column' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested the webpack 4 app in the earlier commit, will retest on main when merged.
🎉 congrats @devongovett and @snowystinger ! |
as the issue is already closed and merged, is there a patch release estimate? |
@abdulhdr1 if it helps, there are nightly releases of |
When will this reach packages like |
This will be released in the next week. Hold tight! |
Closes #2881
This re-adds support for Node ESM after it was reverted in #3839 due to breaking webpack 4. Now we use a new strategy which distributes three files for each module:
dist/main.js
– the CommonJS version in the "main" field, used by node when required, jest, etc.dist/module.js
– the legacy ESM version in the "module" field, used by webpack 4 and other tools that don't support package.json exports. This is needed because.mjs
doesn't work properly in webpack 4.dist/import.mjs
– the modern ESM version in the "exports.import" field, used by Node and other tools supporting exports. This is the exact same asdist/module.js
but with the.mjs
extension for Node.I also tried using
"type": "module"
in package.json to avoid the third entry point, but this broke other things since it applies to all.js
files and not just thedist
directory.The icons now distribute two versions each:
IconName.js
– the CommonJS versionIconName.module.mjs
– the ESM version. This is specially not namedIconName.mjs
so that webpack 4 does not try to resolve it and then fail to resolve the imports. Only tools that support package.json exports will resolve this file.