From 08e347949f7f5fc40bbe3351ecf01f869e69fd47 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 1 May 2023 11:48:25 +0100 Subject: [PATCH 1/3] fix(webpack): remove support for deprecated `build.extend` --- packages/webpack/src/utils/config.ts | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/packages/webpack/src/utils/config.ts b/packages/webpack/src/utils/config.ts index c2bef5998536..33cb7f3c92cf 100644 --- a/packages/webpack/src/utils/config.ts +++ b/packages/webpack/src/utils/config.ts @@ -57,31 +57,6 @@ export function fileName (ctx: WebpackConfigContext, key: string) { } export function getWebpackConfig (ctx: WebpackConfigContext): Configuration { - const { options, config } = ctx - - // TODO - const builder = {} - const loaders: any[] = [] - - // @ts-expect-error TODO: remove support for `build.extend` in v3.5 - const { extend } = options.build - if (typeof extend === 'function') { - const extendedConfig = extend.call( - builder, - config, - { loaders, ...ctx } - ) || config - - const pragma = /@|#/ - const { devtool } = extendedConfig - if (typeof devtool === 'string' && pragma.test(devtool)) { - extendedConfig.devtool = devtool.replace(pragma, '') - logger.warn(`devtool has been normalized to ${extendedConfig.devtool} as webpack documented value`) - } - - return extendedConfig - } - // Clone deep avoid leaking config between Client and Server - return cloneDeep(config) + return cloneDeep(ctx.config) } From 4d8f2e0e835a83b7adff0ae636c2459e423ffe19 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 3 May 2023 22:02:41 +0100 Subject: [PATCH 2/3] feat: warn when `build.extend` is present in user projects --- packages/webpack/src/utils/config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/webpack/src/utils/config.ts b/packages/webpack/src/utils/config.ts index 33cb7f3c92cf..968d98209557 100644 --- a/packages/webpack/src/utils/config.ts +++ b/packages/webpack/src/utils/config.ts @@ -57,6 +57,10 @@ export function fileName (ctx: WebpackConfigContext, key: string) { } export function getWebpackConfig (ctx: WebpackConfigContext): Configuration { + // @ts-expect-error deprecating a property from Nuxt 2 + if (ctx.options.build.extend) { + logger.warn('[nuxt] The `webpack.build.extend` property does not exist in Nuxt 3. Instead you can extend the webpack config using the `webpack:config` hook.') + } // Clone deep avoid leaking config between Client and Server return cloneDeep(ctx.config) } From 4943c09ad736f05623a6626628db3ac9e9b9d5a9 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 4 May 2023 10:41:41 +0100 Subject: [PATCH 3/3] fix: only deprecate `build.extend` for now --- packages/webpack/src/utils/config.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/webpack/src/utils/config.ts b/packages/webpack/src/utils/config.ts index 968d98209557..5727250402c2 100644 --- a/packages/webpack/src/utils/config.ts +++ b/packages/webpack/src/utils/config.ts @@ -57,10 +57,27 @@ export function fileName (ctx: WebpackConfigContext, key: string) { } export function getWebpackConfig (ctx: WebpackConfigContext): Configuration { - // @ts-expect-error deprecating a property from Nuxt 2 - if (ctx.options.build.extend) { - logger.warn('[nuxt] The `webpack.build.extend` property does not exist in Nuxt 3. Instead you can extend the webpack config using the `webpack:config` hook.') + // @ts-expect-error TODO: remove support for `build.extend` in v3.6 + const { extend } = ctx.options.build + if (typeof extend === 'function') { + logger.warn('[nuxt] The `build.extend` and `webpack.build.extend` properties have been deprecated in Nuxt 3 for some time and will be removed in a future minor release. Instead, you can extend webpack config using the `webpack:config` hook.') + + const extendedConfig = extend.call( + {}, + ctx.config, + { loaders: [], ...ctx } + ) || ctx.config + + const pragma = /@|#/ + const { devtool } = extendedConfig + if (typeof devtool === 'string' && pragma.test(devtool)) { + extendedConfig.devtool = devtool.replace(pragma, '') + logger.warn(`devtool has been normalized to ${extendedConfig.devtool} as webpack documented value`) + } + + return extendedConfig } + // Clone deep avoid leaking config between Client and Server return cloneDeep(ctx.config) }