11import fs from 'fs-extra'
22import path from 'node:path'
33import { fileURLToPath } from 'node:url'
4+ import * as vite from 'vite'
45import {
56 build ,
67 normalizePath ,
@@ -98,9 +99,12 @@ export async function bundle(
9899 app : path . resolve ( APP_PATH , ssr ? 'ssr.js' : 'index.js' ) ,
99100 ...input
100101 } ,
101- // important so that each page chunk and the index export things for each
102- // other
103- preserveEntrySignatures : 'allow-extension' ,
102+ // @ts -ignore skip setting it for rolldown-vite since it doesn't support `preserveEntrySignatures` yet
103+ ...( vite . rolldownVersion
104+ ? undefined
105+ : // important so that each page chunk and the index export things for each
106+ // other
107+ { preserveEntrySignatures : 'allow-extension' } ) ,
104108 output : {
105109 sanitizeFileName,
106110 ...rollupOptions ?. output ,
@@ -118,44 +122,52 @@ export async function bundle(
118122 ? `${ config . assetsDir } /chunks/ui-custom.[hash].js`
119123 : `${ config . assetsDir } /chunks/[name].[hash].js`
120124 } ,
121- manualChunks ( id , ctx ) {
122- // move known framework code into a stable chunk so that
123- // custom theme changes do not invalidate hash for all pages
124- if (
125- id . startsWith ( '\0vite' ) ||
126- ctx . getModuleInfo ( id ) ?. meta [ 'vite:asset' ]
127- ) {
128- return 'framework'
129- }
130- if ( id . includes ( 'plugin-vue:export-helper' ) ) {
131- return 'framework'
132- }
133- if (
134- id . includes ( `${ clientDir } /app` ) &&
135- id !== `${ clientDir } /app/index.js`
136- ) {
137- return 'framework'
138- }
139- if (
140- isEagerChunk ( id , ctx . getModuleInfo ) &&
141- / @ v u e \/ ( r u n t i m e | s h a r e d | r e a c t i v i t y ) / . test ( id )
142- ) {
143- return 'framework'
144- }
125+ // @ts -ignore skip setting it for rolldown-vite since it doesn't support `manualChunks`
126+ ...( vite . rolldownVersion
127+ ? undefined
128+ : {
129+ manualChunks (
130+ id : string ,
131+ ctx : Pick < Rollup . PluginContext , 'getModuleInfo' >
132+ ) {
133+ // move known framework code into a stable chunk so that
134+ // custom theme changes do not invalidate hash for all pages
135+ if (
136+ id . startsWith ( '\0vite' ) ||
137+ ctx . getModuleInfo ( id ) ?. meta [ 'vite:asset' ]
138+ ) {
139+ return 'framework'
140+ }
141+ if ( id . includes ( 'plugin-vue:export-helper' ) ) {
142+ return 'framework'
143+ }
144+ if (
145+ id . includes ( `${ clientDir } /app` ) &&
146+ id !== `${ clientDir } /app/index.js`
147+ ) {
148+ return 'framework'
149+ }
150+ if (
151+ isEagerChunk ( id , ctx . getModuleInfo ) &&
152+ / @ v u e \/ ( r u n t i m e | s h a r e d | r e a c t i v i t y ) / . test ( id )
153+ ) {
154+ return 'framework'
155+ }
145156
146- if (
147- ( id . startsWith ( `${ clientDir } /theme-default` ) ||
148- ! excludedModules . some ( ( i ) => id . includes ( i ) ) ) &&
149- staticImportedByEntry (
150- id ,
151- ctx . getModuleInfo ,
152- cacheTheme ,
153- themeEntryRE
154- )
155- ) {
156- return 'theme'
157- }
158- }
157+ if (
158+ ( id . startsWith ( `${ clientDir } /theme-default` ) ||
159+ ! excludedModules . some ( ( i ) => id . includes ( i ) ) ) &&
160+ staticImportedByEntry (
161+ id ,
162+ ctx . getModuleInfo ,
163+ cacheTheme ,
164+ themeEntryRE
165+ )
166+ ) {
167+ return 'theme'
168+ }
169+ }
170+ } )
159171 } )
160172 }
161173 }
0 commit comments