Skip to content

Commit 1458e5c

Browse files
committed
Revert "fix(nextjs): Ensure Webpack plugin is available after dynamic require (#8584)"
This reverts commit 7c51b9e.
1 parent aff5677 commit 1458e5c

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/* eslint-disable max-lines */
33
import { getSentryRelease } from '@sentry/node';
44
import { arrayify, dropUndefinedKeys, escapeStringForRegex, loadModule, logger } from '@sentry/utils';
5-
import type SentryCliPlugin from '@sentry/webpack-plugin';
65
import * as chalk from 'chalk';
76
import * as fs from 'fs';
87
import * as path from 'path';
@@ -313,16 +312,15 @@ export function constructWebpackConfigFunction(
313312
// without, the option to use `hidden-source-map` only applies to the client-side build.
314313
newConfig.devtool = userSentryOptions.hideSourceMaps && !isServer ? 'hidden-source-map' : 'source-map';
315314

316-
const SentryWebpackPlugin = loadModule<SentryCliPlugin>('@sentry/webpack-plugin');
317-
if (SentryWebpackPlugin) {
318-
newConfig.plugins = newConfig.plugins || [];
319-
newConfig.plugins.push(
320-
// @ts-expect-error - this exists, the dynamic import just doesn't know about it
321-
new SentryWebpackPlugin(
322-
getWebpackPluginOptions(buildContext, userSentryWebpackPluginOptions, userSentryOptions),
323-
),
324-
);
325-
}
315+
const SentryWebpackPlugin = loadModule('@sentry/webpack-plugin');
316+
317+
newConfig.plugins = newConfig.plugins || [];
318+
newConfig.plugins.push(
319+
// @ts-expect-error - this exists, the dynamic import just doesn't know about it
320+
new SentryWebpackPlugin(
321+
getWebpackPluginOptions(buildContext, userSentryWebpackPluginOptions, userSentryOptions),
322+
),
323+
);
326324
}
327325
}
328326

@@ -771,10 +769,10 @@ function shouldEnableWebpackPlugin(buildContext: BuildContext, userSentryOptions
771769
// architecture-specific version of the `sentry-cli` binary. If `yarn install`, `npm install`, or `npm ci` are run
772770
// with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users
773771
// try to build their apps.
774-
const SentryWebpackPlugin = loadModule<SentryCliPlugin>('@sentry/webpack-plugin');
772+
const SentryWebpackPlugin = loadModule('@sentry/webpack-plugin');
775773

776774
// @ts-expect-error - this exists, the dynamic import just doesn't know it
777-
if (!SentryWebpackPlugin || !SentryWebpackPlugin.cliBinaryExists()) {
775+
if (!SentryWebpackPlugin.cliBinaryExists()) {
778776
// eslint-disable-next-line no-console
779777
console.error(
780778
`${chalk.red('error')} - ${chalk.bold('Sentry CLI binary not found.')} Source maps will not be uploaded.\n`,

0 commit comments

Comments
 (0)