From cf330553d90a0bd14298cb90b3b47cf451e8f936 Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Thu, 11 Sep 2025 09:01:44 +0800 Subject: [PATCH 1/3] fix: splitChunks.chunks when using Rspack --- packages/next/src/build/webpack-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index b7bd3f408953e..5ff2a5e8f2e7a 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -1188,7 +1188,7 @@ export default async function getBaseWebpackConfig( chunks: isRspack ? // using a function here causes noticable slowdown // in rspack - /(?!polyfills|main|pages\/_app)/ + /^(?!(polyfills|main|pages\/_app)$).*$/ : (chunk: any) => !/^(polyfills|main|pages\/_app)$/.test(chunk.name), From 6439e32d041e55b5b705627914e5fc4cf885506f Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Thu, 11 Sep 2025 09:40:32 +0800 Subject: [PATCH 2/3] fix: framework.test --- packages/next/src/build/webpack-config.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index 5ff2a5e8f2e7a..420bec7e252eb 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -1198,12 +1198,14 @@ export default async function getBaseWebpackConfig( chunks: 'all' as const, name: 'framework', layer: RSPACK_DEFAULT_LAYERS_REGEX, - test: /[/]node_modules[/](react|react-dom|next[/]dist[/]compiled[/](react|react-dom)(-experimental)?)[/]/, + test: new RegExp( + `^(${topLevelFrameworkPaths.map((p) => `(${p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`).join('|')})` + ), priority: 40, enforce: true, }, lib: { - test: /[/]node_modules[/](?!.*\.(css|scss|sass|less|styl)$)/, + test: /[\\/]node_modules[\\/](?!.*\.(css|scss|sass|less|styl)$)/, name: 'lib', chunks: 'all', priority: 30, From e0337e847409d8c389fc009d17a441e2b8ce7a4a Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Mon, 15 Sep 2025 08:13:48 +0800 Subject: [PATCH 3/3] fix: rspack cacheGroups --- packages/next/src/build/webpack-config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index 420bec7e252eb..6d55d0d8c4c8c 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -1199,13 +1199,13 @@ export default async function getBaseWebpackConfig( name: 'framework', layer: RSPACK_DEFAULT_LAYERS_REGEX, test: new RegExp( - `^(${topLevelFrameworkPaths.map((p) => `(${p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`).join('|')})` + `^(${topLevelFrameworkPaths.map((p) => `(${escapeStringRegexp(p)})`).join('|')})` ), priority: 40, enforce: true, }, lib: { - test: /[\\/]node_modules[\\/](?!.*\.(css|scss|sass|less|styl)$)/, + test: /[/]node_modules[/](?!.*\.(css|scss|sass|less|styl)$)/, name: 'lib', chunks: 'all', priority: 30,