From bed202dbcc8f3954c12aaef993369b29ff47211e Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 13 Mar 2023 12:31:57 +0800 Subject: [PATCH] fix: fix chunking logic that causes breakage follow up of 905f58b fix #2072 fix #2073 fix #2074 fix #2075 --- src/node/build/bundle.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/node/build/bundle.ts b/src/node/build/bundle.ts index 5f46061c..c42f7d46 100644 --- a/src/node/build/bundle.ts +++ b/src/node/build/bundle.ts @@ -110,22 +110,29 @@ export async function bundle( : 'assets/chunks/[name].[hash].js' }, manualChunks(id, ctx) { - // optimize default theme chunking - if ( - id.includes(`${clientDir}/theme-default`) && - !lazyDefaultThemeComponentsRE.test(id) - ) { + if (lazyDefaultThemeComponentsRE.test(id)) { + return + } + if (id.startsWith(`${clientDir}/theme-default`)) { return 'theme' } // move known framework code into a stable chunk so that // custom theme changes do not invalidate hash for all pages + if (id.startsWith('\0vite')) { + return 'framework' + } if (id.includes('plugin-vue:export-helper')) { return 'framework' } + if ( + id.includes(`${clientDir}/app`) && + id !== `${clientDir}/app/index.js` + ) { + return 'framework' + } if ( isEagerChunk(id, ctx.getModuleInfo) && - (/@vue\/(runtime|shared|reactivity)/.test(id) || - id.includes(clientDir)) + /@vue\/(runtime|shared|reactivity)/.test(id) ) { return 'framework' }