Verify canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #85~20.04.1-Ubuntu SMP Mon Jul 17 09:42:39 UTC 2023
Binaries:
Node: 18.16.0
npm: 9.5.1
Yarn: 1.22.18
pnpm: 8.6.7
Relevant Packages:
next: 13.4.12
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: N/A
Next.js Config:
output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
https://github.com/replayio/nextjs-inaccurate-sourcemaps
To Reproduce
Alternatively, you can look at these sourcemaps here:
Describe the Bug
I've noticed that the sourcemaps produced by Next.js are inaccurate for some sources, making it impossible for debuggers to show scopes with original (rather than generated) variable names.
This seems to be the case for all sources under node_modules.
To reproduce the problem I've used create-next-app to create an app and copied node_modules/@swc/helpers/esm/_interop_require_wildcard.js to src/_interop_require_wildcard.js. This is what a sourcemap visualizer shows for these two copies of the same source:
node_modules/@swc/helpers/esm/_interop_require_wildcard.js:

src/_interop_require_wildcard.js:

Expected Behavior
Sourcemaps for sources under node_modules should be accurate.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #85~20.04.1-Ubuntu SMP Mon Jul 17 09:42:39 UTC 2023 Binaries: Node: 18.16.0 npm: 9.5.1 Yarn: 1.22.18 pnpm: 8.6.7 Relevant Packages: next: 13.4.12 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: N/A Next.js Config: output: N/AWhich area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
https://github.com/replayio/nextjs-inaccurate-sourcemaps
To Reproduce
npm run build.next/static/chunks/main-26f0defd1fe4aedb.js[.map]to https://evanw.github.io/source-map-visualization/webpack://_N_E/node_modules/@swc/helpers/esm/_interop_require_wildcard.jsas the original source.next/static/chunks/pages/_app-27374a655d3a2ebe.js[.map]to https://evanw.github.io/source-map-visualization/ and selectwebpack://_N_E/src/_interop_require_wildcard.jsAlternatively, you can look at these sourcemaps here:
webpack://_N_E/node_modules/@swc/helpers/esm/_interop_require_wildcard.js: https://app.replay.io/recording/5072126e-507f-43d9-8c9e-889ad2bfd0dd/sourcemap/o4-80-c194bb-ec5646webpack://_N_E/src/_interop_require_wildcard.js: https://app.replay.io/recording/5072126e-507f-43d9-8c9e-889ad2bfd0dd/sourcemap/o6-6-c194bb-5d30d7Describe the Bug
I've noticed that the sourcemaps produced by Next.js are inaccurate for some sources, making it impossible for debuggers to show scopes with original (rather than generated) variable names.
This seems to be the case for all sources under
node_modules.To reproduce the problem I've used create-next-app to create an app and copied
node_modules/@swc/helpers/esm/_interop_require_wildcard.jstosrc/_interop_require_wildcard.js. This is what a sourcemap visualizer shows for these two copies of the same source:node_modules/@swc/helpers/esm/_interop_require_wildcard.js:src/_interop_require_wildcard.js:Expected Behavior
Sourcemaps for sources under
node_modulesshould be accurate.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response