diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/package.json b/packages/e2e-tests/test-applications/nextjs-app-dir/package.json index d8701ef8df7c..08509afe0264 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/package.json +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/package.json @@ -19,7 +19,7 @@ "@types/node": "18.11.17", "@types/react": "18.0.26", "@types/react-dom": "18.0.9", - "next": "13.2.4", + "next": "13.4.12", "react": "18.2.0", "react-dom": "18.2.0", "typescript": "4.9.5", diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index 49f450bb27a4..e406c3da1560 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -1,8 +1,8 @@ /* eslint-disable complexity */ /* 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 { 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'; @@ -313,16 +313,12 @@ 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), - ), - ); - } + newConfig.plugins = newConfig.plugins || []; + newConfig.plugins.push( + new SentryWebpackPlugin( + getWebpackPluginOptions(buildContext, userSentryWebpackPluginOptions, userSentryOptions), + ), + ); } } @@ -771,10 +767,7 @@ 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 || !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`, diff --git a/packages/nextjs/src/config/withSentryConfig.ts b/packages/nextjs/src/config/withSentryConfig.ts index 86f8c5a67031..a9405913560a 100644 --- a/packages/nextjs/src/config/withSentryConfig.ts +++ b/packages/nextjs/src/config/withSentryConfig.ts @@ -6,7 +6,6 @@ import type { SentryWebpackPluginOptions, UserSentryOptions, } from './types'; -import { constructWebpackConfigFunction } from './webpack'; let showedExportModeTunnelWarning = false; @@ -46,6 +45,7 @@ function getFinalConfigObject( userSentryOptions: UserSentryOptions, userSentryWebpackPluginOptions: Partial, ): NextConfigObject { + const { constructWebpackConfigFunction } = module.require('./webpack'); // Next 12.2.3+ warns about non-canonical properties on `userNextConfig`. delete incomingUserNextConfigObject.sentry;