From 3c39c37ad13cfe58ffd430590c287fd952010e42 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 28 Jul 2023 11:37:27 +0200 Subject: [PATCH] Revert "fix(nextjs): Avoid importing `SentryWebpackPlugin` in dev mode (#8557)" This reverts commit 0ca73897a895d1673d0a7b2c3145b10dd52953f3. --- packages/nextjs/src/config/webpack.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index 56d0e64a9559..e406c3da1560 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -1,7 +1,8 @@ /* eslint-disable complexity */ /* eslint-disable max-lines */ import { getSentryRelease } from '@sentry/node'; -import { arrayify, dropUndefinedKeys, escapeStringForRegex, loadModule, logger } from '@sentry/utils'; +import { arrayify, dropUndefinedKeys, escapeStringForRegex, logger } from '@sentry/utils'; +import { default as SentryWebpackPlugin } from '@sentry/webpack-plugin'; import * as chalk from 'chalk'; import * as fs from 'fs'; import * as path from 'path'; @@ -312,11 +313,8 @@ export function constructWebpackConfigFunction( // without, the option to use `hidden-source-map` only applies to the client-side build. newConfig.devtool = userSentryOptions.hideSourceMaps && !isServer ? 'hidden-source-map' : 'source-map'; - const SentryWebpackPlugin = loadModule('@sentry/webpack-plugin'); - newConfig.plugins = newConfig.plugins || []; newConfig.plugins.push( - // @ts-expect-error - this exists, the dynamic import just doesn't know about it new SentryWebpackPlugin( getWebpackPluginOptions(buildContext, userSentryWebpackPluginOptions, userSentryOptions), ), @@ -769,9 +767,6 @@ function shouldEnableWebpackPlugin(buildContext: BuildContext, userSentryOptions // architecture-specific version of the `sentry-cli` binary. If `yarn install`, `npm install`, or `npm ci` are run // with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users // try to build their apps. - const SentryWebpackPlugin = loadModule('@sentry/webpack-plugin'); - - // @ts-expect-error - this exists, the dynamic import just doesn't know it if (!SentryWebpackPlugin.cliBinaryExists()) { // eslint-disable-next-line no-console console.error(