-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(node): Make ESM output valid Node ESM #10928
Conversation
Tim you're a hero 🫡 |
This may work together with: #10960 |
we would like to start using node protocol imports in the SDK to unblock #10960 and #10928 This requires us to have a minimum supported Node version of `14.18.0` as per https://2ality.com/2021/12/node-protocol-imports.html
I make a load of changes to the deprecated |
We can |
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.
awesome!
Opened prisma/prisma#23410 for prisma being CJS only. |
Some bundlers, especially older ones, don't support resolving
.mjs
files out of the box. To retain compatibility with these bundlers without requiring users to adjust their configurations, we need to keep all our ESM output as.js
files.So node.js loads these as modules, we output a
package.json
into each./build/esm
output directory containing simply{ "type": "module" }
. This works because whenever node.js is asked to load a.js
file, it tries to work out whether this is CJS or ESM by searching up through parent directories until it finds apackage.json
with thetype
set.This PR:
package.json
into the ESM outputexports
that @AbhiPrasad worked out for feat: Emit *.mjs files across all packages #10833next/router
which is CJS (at least in v10)@prisma/instrumentation
which is CJS@sentry/node
default integrations when running as ESMThis PR also makes some unrelated changes: