@@ -620,7 +620,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
620620 } ,
621621
622622 async renderChunk ( code , chunk , opts , meta ) {
623- let chunkCSS = ''
623+ let chunkCSS : string | undefined
624624 const renderedModules = new Proxy (
625625 { } as Record < string , RenderedModule | undefined > ,
626626 {
@@ -661,7 +661,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
661661 isPureCssChunk = false
662662 }
663663
664- chunkCSS += styles . get ( id )
664+ chunkCSS = ( chunkCSS || '' ) + styles . get ( id )
665665 } else if ( ! isJsChunkEmpty ) {
666666 // if the module does not have a style, then it's not a pure css chunk.
667667 // this is true because in the `transform` hook above, only modules
@@ -824,7 +824,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
824824 }
825825 }
826826
827- if ( chunkCSS ) {
827+ if ( chunkCSS !== undefined ) {
828828 if ( isPureCssChunk && ( opts . format === 'es' || opts . format === 'cjs' ) ) {
829829 // this is a shared CSS-only chunk that is empty.
830830 pureCssChunks . add ( chunk )
@@ -852,7 +852,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
852852
853853 // wait for previous tasks as well
854854 chunkCSS = await codeSplitEmitQueue . run ( async ( ) => {
855- return finalizeCss ( chunkCSS , true , config )
855+ return finalizeCss ( chunkCSS ! , true , config )
856856 } )
857857
858858 // emit corresponding css file
0 commit comments