sentry-docs icon indicating copy to clipboard operation
sentry-docs copied to clipboard

Document that JS source maps are not required to be shipped in production

Open viddo opened this issue 1 year ago • 1 comments

Core or SDK?

Platform/SDK

Which part? Which one?

Source Maps (JS)

Description

I do want sourcemaps but I do not want to ship them in production. There's no information around this under https://docs.sentry.io/platforms/javascript/sourcemaps/ but for some reason it's only mentioned for the NextJS "platform": https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map:

Depending on your deployment setup, adding sentry/nextjs to your app may cause your source code to be visible in browser devtools when it wasn't before. (This happens because of the default behavior of webpack's source-map built-in devtool.) To prevent this, you can use hidden-source-map rather than source-map, which will prevent your built files from containing a sourceMappingURL comment, thus making sourcemaps invisible to the browser. To use hidden-source-map, add a sentry object to nextConfig above, and set the hideSourceMaps option to true: …

I am not using NextJS, but I do use Webpack. I only found this through Github issues after searching for an answer. I think it would help others too that don't use NextJS if this would be fully documented.

Related open issues I found while searching for an answer around this:

  • https://github.com/getsentry/sentry-javascript/issues/4489
  • https://github.com/getsentry/sentry/issues/20916

Suggested Solution

  • Hoist or also call out that source maps are not required to be shipped in production in the general docs, and that one can configure one's build tooling to keep them hidden, e.g. under https://docs.sentry.io/platforms/javascript/sourcemaps/ or the troubleshooting sub-page perhaps
  • Document under each build tool page how to configure for public vs hidden source maps, e.g. for Webpack I'd probably expect a mention about devtool: 'hidden-source-map' under this sub-section: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/webpack/#configuration

viddo avatar Mar 26 '24 15:03 viddo

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] avatar Mar 26 '24 15:03 getsantry[bot]

Hey, thank you for raising this, and sorry this kind of fell of the radar.

We'll try to update the docs to clarify this even outside of Next.js!

mydea avatar Sep 06 '24 08:09 mydea