Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/browser
SDK Version
8.11.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
Any
Steps to Reproduce
Scenario A:
- Create new Vite project;
- Install
@sentry/browser;
- Call
Sentry.init in code;
- Run Vite in dev mode;
- Open devtools and navigate to Sources/Debugger tabs;
- Open
node_modules folder.
Scenario B:
- Create new Vite project;
- Install
@sentry/browser;
- Call
Sentry.init;
- Add sourcemaps plugin to
vite.config.ts;
- Run Vite build.
Expected Result
Scenario A:
Sources for @sentry/core are located in node_modules/@sentry/core folder in Sources/Debugger.
And sources for @sentry/utils are located in node_modules/@sentry/utils folder in Sources/Debugger.
Scenario B:
Build is successful.
Actual Result
Scenario A:
Sources for both @sentry/core and @sentry/utils are mixed and found in different folders. They are found in:
node_modules/src.
node_modules/@sentry/src.
See screenshots:


Scenario B:
Build fails with error:
Multiple conflicting contents for sourcemap source D:\work\test-widget\node_modules\@sentry\src\envelope.ts
at getRollupError (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/parseAst.js:396:41)
at error (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/parseAst.js:392:42)
at Link.traceMappings (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17774:32)
at collapseSourcemaps (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17858:63)
at transformChunk (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17962:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18008:17
at async Promise.all (index 1)
at async transformChunksAndGenerateContentHashes (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18003:5)
at async renderChunks (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17912:137) {
code: 'SOURCEMAP_BROKEN'
}
Analysis:
Errors are caused by the content of *.js.map files in published npm packages. Field sources contains extra ../ (to parent folder). As a result, the sources path is mapped outside its own package folder.
Build fails because sources of envelope.js from both @sentry/core and @sentry/utils maps by envelope.map.js to the same path: D:\work\test-widget\node_modules\@sentry\src\envelope.ts.
See screenshot:

In order to fix the issue, the path should be ../src/envelope.ts instead of ../../src/envelope.ts or the content of entire packages should be in an additional subfolder.
Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/browser
SDK Version
8.11.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
Any
Steps to Reproduce
Scenario A:
@sentry/browser;Sentry.initin code;node_modulesfolder.Scenario B:
@sentry/browser;Sentry.init;vite.config.ts;Expected Result
Scenario A:
Sources for
@sentry/coreare located innode_modules/@sentry/corefolder in Sources/Debugger.And sources for
@sentry/utilsare located innode_modules/@sentry/utilsfolder in Sources/Debugger.Scenario B:
Build is successful.
Actual Result
Scenario A:
Sources for both
@sentry/coreand@sentry/utilsare mixed and found in different folders. They are found in:node_modules/src.node_modules/@sentry/src.See screenshots:


Scenario B:
Build fails with error:
Analysis:
Errors are caused by the content of
*.js.mapfiles in published npm packages. Fieldsourcescontains extra../(to parent folder). As a result, the sources path is mapped outside its own package folder.Build fails because sources of
envelope.jsfrom both@sentry/coreand@sentry/utilsmaps byenvelope.map.jsto the same path:D:\work\test-widget\node_modules\@sentry\src\envelope.ts.See screenshot:

In order to fix the issue, the path should be
../src/envelope.tsinstead of../../src/envelope.tsor the content of entire packages should be in an additional subfolder.