Skip to content

Commit bea93f9

Browse files
author
Luca Forstner
committed
nextjs
1 parent 14a42d0 commit bea93f9

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

packages/nextjs/src/config/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ export type IgnoreWarningsOption = (
470470
// The two possible formats for providing custom webpack config in `next.config.js`
471471
export type WebpackConfigFunction = (config: WebpackConfigObject, options: BuildContext) => WebpackConfigObject;
472472
export type WebpackConfigObject = {
473-
devtool?: string;
473+
devtool?: string | boolean;
474474
plugins?: Array<WebpackPluginInstance>;
475475
entry: WebpackEntryProperty;
476476
output: { filename: string; path: string };

packages/nextjs/src/config/webpack.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,33 @@ export function constructWebpackConfigFunction(
336336

337337
if (sentryWebpackPlugin) {
338338
if (!userSentryOptions.sourcemaps?.disable) {
339+
// TODO(v9): Remove this warning
340+
if (newConfig.devtool === false) {
341+
const runtimePrefix = !isServer ? 'Client' : runtime === 'edge' ? 'Edge' : 'Node.js';
342+
// eslint-disable-next-line no-console
343+
console.warn(
344+
`[@sentry/nextjs - ${runtimePrefix}] You disabled sourcemaps with the Webpack \`devtool\` option. Currently, the Sentry SDK will override this option to generate sourcemaps. In future versions, the Sentry SDK will not override the \`devtool\` option if you explicitly disable it. If you want to generate and upload sourcemaps please set the \`devtool\` option to true or undefined.`,
345+
);
346+
}
347+
348+
// TODO(v9): Remove this warning and print warning in case source map deletion is auto configured
349+
if (!isServer && !userSentryOptions.sourcemaps?.deleteSourcemapsAfterUpload) {
350+
// eslint-disable-next-line no-console
351+
console.warn(
352+
"[@sentry/nextjs] The Sentry SDK has enabled source map generation for your Next.js app. If you don't want to serve Source Maps to your users, either set the `deleteSourceMapsAfterUpload` option to true, or manually delete the source maps after the build. In future Sentry SDK versions `deleteSourceMapsAfterUpload` will default to `true`.",
353+
);
354+
}
355+
339356
// `hidden-source-map` produces the same sourcemaps as `source-map`, but doesn't include the `sourceMappingURL`
340357
// comment at the bottom. For folks who aren't publicly hosting their sourcemaps, this is helpful because then
341358
// the browser won't look for them and throw errors into the console when it can't find them. Because this is a
342359
// front-end-only problem, and because `sentry-cli` handles sourcemaps more reliably with the comment than
343360
// without, the option to use `hidden-source-map` only applies to the client-side build.
344-
newConfig.devtool =
345-
isServer || userNextConfig.productionBrowserSourceMaps ? 'source-map' : 'hidden-source-map';
361+
if (isServer || userNextConfig.productionBrowserSourceMaps) {
362+
newConfig.devtool = 'source-map';
363+
} else {
364+
newConfig.devtool = 'hidden-source-map';
365+
}
346366
}
347367

348368
newConfig.plugins = newConfig.plugins || [];

0 commit comments

Comments
 (0)