@@ -39,8 +39,8 @@ function pluginDistFileNames(): Plugin[] {
3939 if ( ! ( 'assetFileNames' in rollupOutput ) ) {
4040 rollupOutput . assetFileNames = ( chunkInfo ) => getAssetFileName ( chunkInfo , config )
4141
42- // This Vite plugin is sometimes applied twice => avoid assertUsage() error below
43- // - I don't know why this plugin can be applied twice for the same config. It happened when there was multiple Vike instances installed with one instance being a link to ~/code/vike/packages/vike/
42+ // Sometimes applied twice => avoid assertUsage() error below
43+ // - I don't know why it can be applied twice for the same config. It happened when there was multiple Vike instances installed with one instance being a link to ~/code/vike/packages/vike/
4444 ; ( rollupOutput . assetFileNames as any ) . isTheOneSetByVike = true
4545 assert ( ( rollupOutput . assetFileNames as any ) . isTheOneSetByVike )
4646 } else {
@@ -225,32 +225,6 @@ function workaroundGlob(name: string) {
225225 return name
226226}
227227
228- function getRollupOutputs ( config : ResolvedConfig ) : Rollup . OutputOptions [ ] {
229- // @ts -expect-error is read-only
230- config . build ??= { }
231- config . build . rollupOptions ??= { }
232- config . build . rollupOptions . output ??= { }
233- const { output } = config . build . rollupOptions
234- if ( ! isArray ( output ) ) {
235- return [ output ]
236- }
237- return output
238- }
239- function getRolldownOutputs ( config : ResolvedConfig ) : RolldownOutputOptions [ ] {
240- // @ts -expect-error is read-only
241- config . build ??= { }
242- // @ts -ignore
243- config . build . rolldownOptions ??= { }
244- // @ts -ignore
245- config . build . rolldownOptions . output ??= { }
246- // @ts -ignore
247- const { output } = config . build . rolldownOptions
248- if ( ! isArray ( output ) ) {
249- return [ output ]
250- }
251- return output as any [ ]
252- }
253-
254228// Workaround for Vite CSS duplication bug: https://github.com/vikejs/vike/issues/1815
255229function disableCSSBundling ( config : ResolvedConfig ) {
256230 if ( isVite8OrAbove ( config ) ) {
@@ -297,7 +271,7 @@ function wrapManualChunks(
297271 optsName : 'rollupOptions' | 'rolldownOptions' ,
298272) {
299273 const manualChunksOriginal = output . manualChunks
300- // This Vite plugin is sometimes applied twice => skip if we already wrapped — same rationale as `isTheOneSetByVike` for assetFileNames above.
274+ // Sometimes applied twice => skip if we already wrapped — same rationale as `isTheOneSetByVike` for assetFileNames above.
301275 if ( ( manualChunksOriginal as any ) ?. isTheOneSetByVike ) return
302276 output . manualChunks = function ( id : string , ...args : unknown [ ] ) {
303277 if ( manualChunksOriginal ) {
@@ -370,3 +344,29 @@ function isVite8OrAbove(config: ResolvedConfig) {
370344 assert ( viteVersion )
371345 return isVersionMatch ( viteVersion , [ '8.0.0' ] )
372346}
347+
348+ function getRollupOutputs ( config : ResolvedConfig ) : Rollup . OutputOptions [ ] {
349+ // @ts -expect-error is read-only
350+ config . build ??= { }
351+ config . build . rollupOptions ??= { }
352+ config . build . rollupOptions . output ??= { }
353+ const { output } = config . build . rollupOptions
354+ if ( ! isArray ( output ) ) {
355+ return [ output ]
356+ }
357+ return output
358+ }
359+ function getRolldownOutputs ( config : ResolvedConfig ) : RolldownOutputOptions [ ] {
360+ // @ts -expect-error is read-only
361+ config . build ??= { }
362+ // @ts -ignore
363+ config . build . rolldownOptions ??= { }
364+ // @ts -ignore
365+ config . build . rolldownOptions . output ??= { }
366+ // @ts -ignore
367+ const { output } = config . build . rolldownOptions
368+ if ( ! isArray ( output ) ) {
369+ return [ output ]
370+ }
371+ return output as any [ ]
372+ }
0 commit comments