From b86d945bc48e9343fa8d4f0ad0037153cd1abd62 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 21 Jan 2025 12:56:51 +0000 Subject: [PATCH 1/2] feat(nextjs): Directly forward `sourcemaps.disable` to webpack plugin --- packages/nextjs/src/config/types.ts | 2 +- packages/nextjs/src/config/webpackPluginOptions.ts | 5 +---- .../nextjs/test/config/webpack/webpackPluginOptions.test.ts | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/nextjs/src/config/types.ts b/packages/nextjs/src/config/types.ts index bbba80e476c8..0a188341ce58 100644 --- a/packages/nextjs/src/config/types.ts +++ b/packages/nextjs/src/config/types.ts @@ -122,7 +122,7 @@ export type SentryBuildOptions = { */ sourcemaps?: { /** - * Disable any functionality related to source maps upload. + * Disable any functionality related to source maps. */ disable?: boolean; diff --git a/packages/nextjs/src/config/webpackPluginOptions.ts b/packages/nextjs/src/config/webpackPluginOptions.ts index 43aea096bdaa..00d2c578cd05 100644 --- a/packages/nextjs/src/config/webpackPluginOptions.ts +++ b/packages/nextjs/src/config/webpackPluginOptions.ts @@ -51,10 +51,6 @@ export function getWebpackPluginOptions( ); } - if (sentryBuildOptions.sourcemaps?.disable) { - sourcemapUploadAssets = []; - } - return { authToken: sentryBuildOptions.authToken, headers: sentryBuildOptions.headers, @@ -69,6 +65,7 @@ export function getWebpackPluginOptions( silent: sentryBuildOptions.silent, url: sentryBuildOptions.sentryUrl, sourcemaps: { + disable: sentryBuildOptions.sourcemaps?.disable, rewriteSources(source) { if (source.startsWith('webpack://_N_E/')) { return source.replace('webpack://_N_E/', ''); diff --git a/packages/nextjs/test/config/webpack/webpackPluginOptions.test.ts b/packages/nextjs/test/config/webpack/webpackPluginOptions.test.ts index d6af815d13cb..c987cda267e4 100644 --- a/packages/nextjs/test/config/webpack/webpackPluginOptions.test.ts +++ b/packages/nextjs/test/config/webpack/webpackPluginOptions.test.ts @@ -173,11 +173,11 @@ describe('getWebpackPluginOptions()', () => { }); }); - it('sets `sourcemaps.assets` to an empty array when `sourcemaps.disable` is true', () => { + it('sets `sourcemaps.disable` plugin options to true when `sourcemaps.disable` is true', () => { const buildContext = generateBuildContext({ isServer: false }); const generatedPluginOptions = getWebpackPluginOptions(buildContext, { sourcemaps: { disable: true } }, undefined); expect(generatedPluginOptions.sourcemaps).toMatchObject({ - assets: [], + disable: true, }); }); From 71422096578d6b301e78a7a3b05de7ff12a86bb8 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 21 Jan 2025 13:19:29 +0000 Subject: [PATCH 2/2] lint --- packages/nextjs/src/config/webpackPluginOptions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nextjs/src/config/webpackPluginOptions.ts b/packages/nextjs/src/config/webpackPluginOptions.ts index 00d2c578cd05..530659b2a703 100644 --- a/packages/nextjs/src/config/webpackPluginOptions.ts +++ b/packages/nextjs/src/config/webpackPluginOptions.ts @@ -23,7 +23,7 @@ export function getWebpackPluginOptions( const distDir = (userNextConfig as NextConfigObject).distDir?.replace(/\\/g, '/') ?? '.next'; const distDirAbsPath = path.posix.join(projectDir, distDir); - let sourcemapUploadAssets: string[] = []; + const sourcemapUploadAssets: string[] = []; const sourcemapUploadIgnore: string[] = []; if (isServer) {