Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nextjs): Add option to use hidden-source-map as webpack devtool value #4436

Merged
merged 2 commits into from
Jan 24, 2022

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Jan 21, 2022

We currently force the value of the webpack option devtool to be source-map, in order to guarantee that the correct sourcemaps are generated during build. There is another devtool value, hidden-source-map, which produces the same maps (so just as good for our purposes), but without adding sourceMappingURL comments at the bottom of the resulting JS files. (Some users prefer this as a way not to have the browser complain when it tries to follow the sourceMappingURL link and comes up empty.)

This PR adds an option that users can pass in their nextjs config, under the key sentry.hideSourceMaps. When this is set to true, the SDK will use hidden-source-map as the devtool value instead of source-map. Note that since this is a front-end-only problem, the option only applies to client-side builds.

The new option is documented in getsentry/sentry-docs#4627.

Fixes #3549.

@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-allow-hidden-sourcemaps branch from 13a2050 to cf6643b Compare January 21, 2022 18:24
@github-actions
Copy link
Contributor

github-actions bot commented Jan 21, 2022

size-limit report

Path Base Size (472cb0c) Current Size Change
@sentry/browser - CDN Bundle (gzipped) 19.68 KB 19.69 KB +0.02% 🔺
@sentry/browser - CDN Bundle (minified) 62.85 KB 62.86 KB +0.01% 🔺
@sentry/browser - Webpack 22.2 KB 22.2 KB 0%
@sentry/browser - Webpack - gzip = false 75.99 KB 75.99 KB 0%
@sentry/react - Webpack 22.24 KB 22.24 KB 0%
@sentry/nextjs Client - Webpack 46.22 KB 46.22 KB 0%
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 28.21 KB 28.22 KB +0.02% 🔺

Verified

This commit was signed with the committer’s verified signature.
joni- Joni Nevalainen
@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-allow-hidden-sourcemaps branch from cf6643b to 6fe684b Compare January 24, 2022 14:59
@lobsterkatie lobsterkatie merged commit 2e32c30 into master Jan 24, 2022
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-allow-hidden-sourcemaps branch January 24, 2022 15:30
lobsterkatie added a commit to getsentry/sentry-docs that referenced this pull request Jan 24, 2022
This documents the option added in getsentry/sentry-javascript#4436, to allow users to use `hidden-source-map` as their webpack `devtool` for client-side builds. (With this option enabled, the same sourcemaps are generated, but the final bundles don't have a `sourceMappingURL` comment, effectively "hiding" the sourcemaps from the browser. Doing this prevents the browser from complaining in situations where the maps are not publicly hosted.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@sentry/nextjs: option for hidden-source-map instead of source-map
2 participants