fix: fix chunking logic that causes breakage

follow up of 905f58b

fix #2072
fix #2073
fix #2074
fix #2075
pull/2040/head
Evan You 2 years ago
parent a7cca23c37
commit bed202dbcc

@ -110,22 +110,29 @@ export async function bundle(
: 'assets/chunks/[name].[hash].js' : 'assets/chunks/[name].[hash].js'
}, },
manualChunks(id, ctx) { manualChunks(id, ctx) {
// optimize default theme chunking if (lazyDefaultThemeComponentsRE.test(id)) {
if ( return
id.includes(`${clientDir}/theme-default`) && }
!lazyDefaultThemeComponentsRE.test(id) if (id.startsWith(`${clientDir}/theme-default`)) {
) {
return 'theme' return 'theme'
} }
// move known framework code into a stable chunk so that // move known framework code into a stable chunk so that
// custom theme changes do not invalidate hash for all pages // custom theme changes do not invalidate hash for all pages
if (id.startsWith('\0vite')) {
return 'framework'
}
if (id.includes('plugin-vue:export-helper')) { if (id.includes('plugin-vue:export-helper')) {
return 'framework' return 'framework'
} }
if (
id.includes(`${clientDir}/app`) &&
id !== `${clientDir}/app/index.js`
) {
return 'framework'
}
if ( if (
isEagerChunk(id, ctx.getModuleInfo) && isEagerChunk(id, ctx.getModuleInfo) &&
(/@vue\/(runtime|shared|reactivity)/.test(id) || /@vue\/(runtime|shared|reactivity)/.test(id)
id.includes(clientDir))
) { ) {
return 'framework' return 'framework'
} }

Loading…
Cancel
Save