ref(build): Relocate vendored deps out of node_modules in npm builds#21503
Open
mydea wants to merge 1 commit into
Open
ref(build): Relocate vendored deps out of node_modules in npm builds#21503mydea wants to merge 1 commit into
node_modules in npm builds#21503mydea wants to merge 1 commit into
Conversation
mydea
added a commit
that referenced
this pull request
Jun 12, 2026
Source span/attribute keys from `@sentry/conventions` instead of the previous OpenTelemetry / vendored convention constants. No functional change. Depends on #21503 (relocates vendored deps out of `node_modules` in the build). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mydea
added a commit
that referenced
this pull request
Jun 12, 2026
Source span/attribute keys from `@sentry/conventions` instead of the previous OpenTelemetry / vendored convention constants. No functional change. Depends on #21503 (relocates vendored deps out of `node_modules` in the build). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mydea
added a commit
that referenced
this pull request
Jun 12, 2026
Source span/attribute keys from `@sentry/conventions` instead of the previous OpenTelemetry / vendored convention constants. No functional change. Depends on #21503 (relocates vendored deps out of `node_modules` in the build). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mydea
added a commit
that referenced
this pull request
Jun 12, 2026
Source span/attribute keys from `@sentry/conventions` instead of the previous OpenTelemetry / vendored convention constants. No functional change. Depends on #21503 (relocates vendored deps out of `node_modules` in the build). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mydea
added a commit
that referenced
this pull request
Jun 12, 2026
Source span/attribute keys from `@sentry/conventions` instead of the previous OpenTelemetry / vendored convention constants. No functional change. Depends on #21503 (relocates vendored deps out of `node_modules` in the build). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mydea
added a commit
that referenced
this pull request
Jun 12, 2026
Source span/attribute keys from `@sentry/conventions` instead of the previous OpenTelemetry / vendored convention constants. No functional change. Depends on #21503 (relocates vendored deps out of `node_modules` in the build). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mydea
added a commit
that referenced
this pull request
Jun 12, 2026
Source span/attribute keys from `@sentry/conventions` instead of the previous OpenTelemetry / vendored convention constants. No functional change. Depends on #21503 (relocates vendored deps out of `node_modules` in the build). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mydea
added a commit
that referenced
this pull request
Jun 12, 2026
Source span/attribute keys from `@sentry/conventions` instead of the previous OpenTelemetry / vendored convention constants. No functional change. Depends on #21503 (relocates vendored deps out of `node_modules` in the build). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mydea
added a commit
that referenced
this pull request
Jun 12, 2026
Source span/attribute keys from `@sentry/conventions` instead of the previous OpenTelemetry / vendored convention constants. No functional change. Depends on #21503 (relocates vendored deps out of `node_modules` in the build). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This was referenced Jun 12, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 625467a. Configure here.
mydea
commented
Jun 12, 2026
Comment on lines
+22
to
+24
| "paths": { | ||
| "@sentry/conventions/attributes": ["../../node_modules/@sentry/conventions/dist/attributes"] | ||
| } |
Member
Author
There was a problem hiding this comment.
this is actually related to follow up PRs but is foundational enough that we may as well also do it here I suppose... this is for the node bundler strategy to be able to resolve the subpath import properly for types.
With `preserveModules: true`, Rollup emits bundled dependencies that resolve from
`node_modules` (e.g. a vendored devDependency like `@sentry/conventions`) into an
output directory literally named `node_modules`. Node treats `node_modules` as a
package-scope boundary, so the `{"type":"module"}` marker we emit at the ESM build
root does NOT apply inside it — Node then loads our ESM `.js` files there as CommonJS
(named imports fail with "is a CommonJS module"), and Vitest externalizes any
`/node_modules/` path and `require()`s it, which additionally breaks on Node 18.
This adds a rollup-utils plugin that relocates such modules to a plain `_external/`
directory (Rollup rewrites the import specifiers automatically), so the scope marker
applies and the heuristics no longer fire. Also maps the `@sentry/conventions/attributes`
subpath in the shared TS config for `node` moduleResolution type builds.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
625467a to
2a83a9f
Compare
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.

Summary
Foundational build-infra change for the
@sentry/conventionsmigration. The per-package@sentry/conventionsPRs depend on this and it should merge first.Root cause
With
preserveModules: true, Rollup emits bundled dependencies that resolve fromnode_modules(e.g. the vendored@sentry/conventionsdevDependency) into an output directory literally namednode_modules(build/esm/node_modules/@sentry/conventions/dist/attributes.js).Node treats
node_modulesas a package-scope boundary: the{"type":"module"}marker we emit at the ESM build root does not apply inside it. Node then loads our ESM.jsfiles there as CommonJS, so named imports fail:The same boundary also makes Vitest externalize the
/node_modules/path andrequire()it, which additionally fails on Node 18 (norequire(esm)support).Fix
A
relocate-vendored-modulesrollup-utils plugin moves bundlednode_modulesdeps to a plain_external/directory (kept undersrcsopreserveModulesroots it at the build root). Rollup rewrites every import specifier to the new location automatically, so thetype:modulescope marker applies and neither the Node ESM/CJS heuristic nor Vitest's externalization fire. Modules with internal relative imports (e.g. the multi-file@sentry/rrwebbundle in replay) are relocated as a unit.Also maps the
@sentry/conventions/attributessubpath inpackages/typescript/tsconfig.jsonfor the repo'snodemoduleResolution type builds.Verified with a full
yarn build:dev(all 45 projects) and by confirming a packed@sentry/react-routerresolves the relocated file as ESM.Ref: #20982
🤖 Generated with Claude Code