From 7355a2f86ea00bca8890fed5723a0eaa29827200 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 12 Mar 2024 15:39:32 +0000 Subject: [PATCH] fix splitChunks --- packages/next/src/build/webpack-config.ts | 4 ++-- .../next/src/build/webpack/plugins/css-chunking-plugin.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index 79de054225029..2f038c1c5555e 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -994,7 +994,7 @@ export default async function getBaseWebpackConfig( // Ensures the framework chunk is not created for App Router. layer: isWebpackDefaultLayer, test(module: any) { - if (module.type.startsWith('css')) return false + if (module.type?.startsWith('css')) return false const resource = module.nameForCondition?.() return resource ? topLevelFrameworkPaths.some((pkgPath) => @@ -1015,7 +1015,7 @@ export default async function getBaseWebpackConfig( nameForCondition: Function }): boolean { return ( - !module.type.startsWith('css') && + !module.type?.startsWith('css') && module.size() > 160000 && /node_modules[/\\]/.test(module.nameForCondition() || '') ) diff --git a/packages/next/src/build/webpack/plugins/css-chunking-plugin.ts b/packages/next/src/build/webpack/plugins/css-chunking-plugin.ts index d6e277eabe875..85c07dd1506e9 100644 --- a/packages/next/src/build/webpack/plugins/css-chunking-plugin.ts +++ b/packages/next/src/build/webpack/plugins/css-chunking-plugin.ts @@ -40,7 +40,7 @@ export class CssChunkingPlugin { } once = true const chunkGraph = compilation.chunkGraph - let changed = false + let changed: undefined | true = undefined const chunkStates = new Map() const chunkStatesByModule = new Map>()