From b69255cdd4bd1e0b819d996a9d9aa89b939cd144 Mon Sep 17 00:00:00 2001 From: Mitchell Heddles Date: Mon, 25 Jul 2022 10:03:20 +1000 Subject: [PATCH] Remove sentry property from returned next config --- packages/nextjs/src/config/index.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/nextjs/src/config/index.ts b/packages/nextjs/src/config/index.ts index 90bc37c4d7d1..546cc411ea47 100644 --- a/packages/nextjs/src/config/index.ts +++ b/packages/nextjs/src/config/index.ts @@ -17,16 +17,26 @@ export function withSentryConfig( if (typeof userNextConfig === 'function') { return function (phase: string, defaults: { defaultConfig: NextConfigObject }): Partial { const materializedUserNextConfig = userNextConfig(phase, defaults); + const webpack = constructWebpackConfigFunction(materializedUserNextConfig, userSentryWebpackPluginOptions); + + // Next 12.2.3+ warns about additional properties on the config + delete materializedUserNextConfig.sentry; + return { ...materializedUserNextConfig, - webpack: constructWebpackConfigFunction(materializedUserNextConfig, userSentryWebpackPluginOptions), + webpack, }; }; } // Otherwise, we can just merge their config with ours and return an object. + const webpack = constructWebpackConfigFunction(userNextConfig, userSentryWebpackPluginOptions); + + // Next 12.2.3+ warns about additional properties on the config + delete userNextConfig.sentry + return { ...userNextConfig, - webpack: constructWebpackConfigFunction(userNextConfig, userSentryWebpackPluginOptions), + webpack, }; }