Skip to content

feat: add hiddenSourceMaps option to prevent sourcemap exposure - #84152

Open
omareltomy wants to merge 4 commits into
vercel:canaryfrom
omareltomy:feat/hidden-sourcemaps-option
Open

feat: add hiddenSourceMaps option to prevent sourcemap exposure#84152
omareltomy wants to merge 4 commits into
vercel:canaryfrom
omareltomy:feat/hidden-sourcemaps-option

Conversation

@omareltomy

Copy link
Copy Markdown
  • Add hiddenSourceMaps boolean option to Next.js config
  • When enabled with productionBrowserSourceMaps, generates 'hidden-source-map' instead of 'source-map'
  • Prevents # sourceMappingURL comments in generated JS bundles
  • Allows error tracking services to use source maps while hiding them from end users
  • Fixes S3/CDN 404 errors when source maps aren't uploaded publicly

Closes #[84095]

- Add hiddenSourceMaps boolean option to Next.js config
- When enabled with productionBrowserSourceMaps, generates 'hidden-source-map' instead of 'source-map'
- Prevents # sourceMappingURL comments in generated JS bundles
- Allows error tracking services to use source maps while hiding them from end users
- Fixes S3/CDN 404 errors when source maps aren't uploaded publicly

Closes #[84095]
@ijjk

ijjk commented Sep 23, 2025

Copy link
Copy Markdown
Member

Allow CI Workflow Run

  • approve CI run for commit: 68f88cf

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Comment thread packages/next/src/build/webpack/config/blocks/base.ts

@omareltomy omareltomy left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now you can't have "hidden source maps" if you're not generating source maps in the first place!

Comment thread packages/next/src/build/webpack/config/blocks/base.ts
DevToolsIgnorePlugin should be applied to both 'source-map' and
'hidden-source-map' since they both generate actual source map files
that benefit from ignore list functionality for debugging.
@holtkampjs

Copy link
Copy Markdown

@omareltomy
It's sad to see this PR hasn't gotten more love. I've recently run into this as an issue.

Looking at Next.js's docs,

Source Maps are enabled by default during development. During production builds, they are disabled to prevent you leaking your source on the client, unless you specifically opt-in with the configuration flag.

It seems clear that even the people who wrote the docs recognize that it's not often ideal to serve your sourcemaps unless that is something you explicitly want to do. However, there are plenty of users who want to generate sourcemaps for use cases such as error log de-obfuscation in logging and monitoring software.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants