Sourcemaps are not being copied to the standalone output folder.
The issue involves sourcemaps not being copied to the `.next/standalone/` folder during the build process. The problem is reproducible and affects debugging. The fix likely involves modifying the build process to include sourcemaps in the standalone output.
https://github.com/afgomez/test-next
Not all sourcemaps are copied over when building a standalone build.
~/code/test-next[main]% pnpm run build
~/code/test-next[main]% find .next/standalone/.next/server/chunks -name '*.js.map' | wc -l
0
~/code/test-next[main]% find .next/server/chunks -name '*.js.map' | wc -l
27
However, the copied files do reference a sourcemap
~/code/test-next[main]% grep -r sourceMappingURL .next/standalone/.next/server/chunks | wc -l
27
Expected:
standalone/ folder.Actual:
standalone/ folder.Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:56 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6041
Available memory (MB): 49152
Available CPU cores: 14
Binaries:
Node: 25.6.1
npm: 11.9.0
Yarn: 1.22.22
pnpm: 10.29.3
Relevant Packages:
next: 16.2.0-canary.37 // Latest available version is detected (16.2.0-canary.37).
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.9.3
Next.js Config:
output: standalone
Output
next build (local)
I can also reproduce this issue in Next 16.1.5.
I could not find anything in the docs mentioning that this is expected behaviour, or that it is configurable in any way.
I noticed because we run the app with node --enable-source-maps, but the stack traces still contained references to minified files. A fix for this issue will make my debugging sessions much easier 🙇
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!