Add option to hide sourcemaps for client side bundle
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template
To Reproduce
npm build
Current vs. Expected behavior
Current:
We use https://nextjs.org/docs/app/api-reference/config/next-config-js/productionBrowserSourceMaps but wont share sources for real users. That's why we don't upload sourcemaps to s3 and just upload them to error tracking system. But it triggers alerts on 404 from our s3.
Expected:
when you enable sourcemaps in nextjs under the hood it sets devtool to source-map - https://github.com/vercel/next.js/blob/9cf9183e0090e0dd322f4604a21f00f00111db4c/packages/next/src/build/webpack/config/blocks/base.ts#L50
Need to have an option to use hidden-source-map for client build - https://webpack.js.org/configuration/devtool/#production. It will solve issue
[!Note]
My report is about webpack specifically. Though, while there might be specific webpack config workarounds, ideally I would prefer an option in next config, that would pass the source-map intention to other bundlers such as Turbopack or Rspack.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Available memory (MB): 4102
Available CPU cores: 2
Binaries:
Node: 20.9.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.10.2
Relevant Packages:
next: 15.6.0-canary.21 // Latest available version is detected (15.6.0-canary.21).
eslint-config-next: N/A
react: 19.1.1
react-dom: 19.1.1
typescript: 5.3.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Webpack
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/next/src/build/webpack/config/blocks/base.ts and the linked reproduction, then trace how productionBrowserSourceMaps configures the client build. Check how the source-map intent could be represented in next.config.js and shared with other bundlers. Done means a documented option produces hidden client source maps without requiring uploads to the public asset host.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js, webpack
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100