feat: Emit *.mjs files across all packages#10833
Closed
AbhiPrasad wants to merge 21 commits intodevelopfrom
Closed
feat: Emit *.mjs files across all packages#10833AbhiPrasad wants to merge 21 commits intodevelopfrom
AbhiPrasad wants to merge 21 commits intodevelopfrom
Conversation
b0d0d93 to
921c283
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Collaborator
|
Node/Remix Integration tests are now passing. Still a few more issues to work through... |
Collaborator
|
Contributor
|
@timfish We likely have to update the paths here: |
This comment was marked as outdated.
This comment was marked as outdated.
timfish
reviewed
Mar 4, 2024
Contributor
|
The nextjs e2e test failures are weird. Next.js should not see the "wrapping target file" paths at all. They should all be bundled away with the rollup call here: |
Member
IIRC my project's |
Collaborator
Collaborator
|
The |
AbhiPrasad
pushed a commit
that referenced
this pull request
Mar 5, 2024
Collaborator
|
Closing in favour of #10928 |
AbhiPrasad
pushed a commit
that referenced
this pull request
Mar 7, 2024
AbhiPrasad
pushed a commit
that referenced
this pull request
Mar 8, 2024
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 a `package.json` with the `type` set.
This PR:
- Adds a Rollup plugin that injects the `package.json` into the ESM
output
- Adds the package `exports` that @AbhiPrasad worked out for #10833
- Fixes an import issue with `next/router` which is CJS (at least in
v10)
- Fixes an import issue with `@prisma/instrumentation` which is CJS
- Ensures that CJS only integrations are not included in the
`@sentry/node` default integrations when running as ESM
This PR also makes some unrelated changes:
- Changes to the old Node SDKs to allow the tests to pass
- Removes the bundle size analysis CI job as it doesn't appears to be
compatible with the node ESM output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


#10046
On the road of proper esm support, this first change introduces
package.jsonexports to each of our packages. Now lets see what breaks 😭This PR has some breaking changes or things that have been disabled to get the build working and tests passing which will need to be revisited later:
modulesIntegrationusesrequireto get the module list and makes no sense for ESMrequire('inspector')or `dynamicRequire('inspector') have been replaced with regular imports. We can't use async import because it introduces async where it can't be supported. This change means we will break Vercel/pkg apps since they build Node without inspector. Vercel/pkg has been deprecated as of Jan 2024.nativeNodeFetchIntegrationis no longer in the default integrations and the export has been removed for now. This integration usesrequireand when I triedimport('opentelemetry-instrumentation-fetch-node')it seemed seemed to break Rollup output in a similar way to this: preserveModules creates wrong output rollup/rollup#3743Other outstanding issues:
Error: Failed to resolve entry for package "https"