Skip to content

Commit ef33250

Browse files
authored
ref(nextjs): Don't use Sentry Webpack Plugin in dev mode (#7901)
1 parent 36d6630 commit ef33250

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

packages/nextjs/src/config/webpack.ts

+9-22
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,14 @@ export function constructWebpackConfigFunction(
285285
// front-end-only problem, and because `sentry-cli` handles sourcemaps more reliably with the comment than
286286
// without, the option to use `hidden-source-map` only applies to the client-side build.
287287
newConfig.devtool = userSentryOptions.hideSourceMaps && !isServer ? 'hidden-source-map' : 'source-map';
288-
}
289288

290-
newConfig.plugins = newConfig.plugins || [];
291-
newConfig.plugins.push(
292-
new SentryWebpackPlugin(
293-
getWebpackPluginOptions(buildContext, userSentryWebpackPluginOptions, userSentryOptions),
294-
),
295-
);
289+
newConfig.plugins = newConfig.plugins || [];
290+
newConfig.plugins.push(
291+
new SentryWebpackPlugin(
292+
getWebpackPluginOptions(buildContext, userSentryWebpackPluginOptions, userSentryOptions),
293+
),
294+
);
295+
}
296296
}
297297

298298
return newConfig;
@@ -584,7 +584,7 @@ export function getWebpackPluginOptions(
584584
userPluginOptions: Partial<SentryWebpackPluginOptions>,
585585
userSentryOptions: UserSentryOptions,
586586
): SentryWebpackPluginOptions {
587-
const { buildId, isServer, webpack, config, dev: isDev, dir: projectDir } = buildContext;
587+
const { buildId, isServer, webpack, config, dir: projectDir } = buildContext;
588588
const userNextConfig = config as NextConfigObject;
589589

590590
const distDirAbsPath = path.resolve(projectDir, userNextConfig.distDir || '.next'); // `.next` is the default directory
@@ -628,7 +628,6 @@ export function getWebpackPluginOptions(
628628
urlPrefix,
629629
entries: [], // The webpack plugin's release injection breaks the `app` directory - we inject the release manually with the value injection loader instead.
630630
release: getSentryRelease(buildId),
631-
dryRun: isDev,
632631
});
633632

634633
checkWebpackPluginOverrides(defaultPluginOptions, userPluginOptions);
@@ -733,7 +732,7 @@ export function getWebpackPluginOptions(
733732

734733
/** Check various conditions to decide if we should run the plugin */
735734
function shouldEnableWebpackPlugin(buildContext: BuildContext, userSentryOptions: UserSentryOptions): boolean {
736-
const { isServer, dev: isDev } = buildContext;
735+
const { isServer } = buildContext;
737736
const { disableServerWebpackPlugin, disableClientWebpackPlugin } = userSentryOptions;
738737

739738
/** Non-negotiable */
@@ -758,18 +757,6 @@ function shouldEnableWebpackPlugin(buildContext: BuildContext, userSentryOptions
758757
return !disableClientWebpackPlugin;
759758
}
760759

761-
/** Situations where the default is to disable the plugin */
762-
763-
// TODO: Are there analogs to Vercel's preveiw and dev modes on other deployment platforms?
764-
765-
if (isDev || process.env.NODE_ENV === 'development') {
766-
// TODO (v8): Right now in dev we set the plugin to dryrun mode, and our boilerplate includes setting the plugin to
767-
// `silent`, so for the vast majority of users, it's as if the plugin doesn't run at all in dev. Making that
768-
// official is technically a breaking change, though, so we probably should wait until v8.
769-
// return false
770-
}
771-
772-
// We've passed all of the tests!
773760
return true;
774761
}
775762

packages/nextjs/test/config/webpack/sentryWebpackPlugin.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ describe('Sentry webpack plugin config', () => {
3939
urlPrefix: '~/_next', // default
4040
entries: [],
4141
release: 'doGsaREgReaT', // picked up from env
42-
dryRun: false, // based on buildContext.dev being false
4342
}),
4443
);
4544
});

0 commit comments

Comments
 (0)