From 825fa94e67a840dbe22611f2a019ed1c2b855305 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 28 Jul 2023 11:37:18 +0200 Subject: [PATCH] Revert "fix(nextjs): Ensure Webpack plugin is available after dynamic require (#8584)" This reverts commit 7c51b9e9b3c8f9156a9e42f1a83395a41e9456a2. --- packages/nextjs/src/config/webpack.ts | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index 49f450bb27a4..56d0e64a9559 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -2,7 +2,6 @@ /* eslint-disable max-lines */ import { getSentryRelease } from '@sentry/node'; import { arrayify, dropUndefinedKeys, escapeStringForRegex, loadModule, logger } from '@sentry/utils'; -import type SentryCliPlugin from '@sentry/webpack-plugin'; import * as chalk from 'chalk'; import * as fs from 'fs'; import * as path from 'path'; @@ -313,16 +312,15 @@ 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'); - if (SentryWebpackPlugin) { - 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), - ), - ); - } + 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), + ), + ); } } @@ -771,10 +769,10 @@ 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'); + const SentryWebpackPlugin = loadModule('@sentry/webpack-plugin'); // @ts-expect-error - this exists, the dynamic import just doesn't know it - if (!SentryWebpackPlugin || !SentryWebpackPlugin.cliBinaryExists()) { + if (!SentryWebpackPlugin.cliBinaryExists()) { // eslint-disable-next-line no-console console.error( `${chalk.red('error')} - ${chalk.bold('Sentry CLI binary not found.')} Source maps will not be uploaded.\n`,