File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
packages/vite/src/node/plugins Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -624,7 +624,8 @@ export function cssPostPlugin(config: ResolvedConfig): RolldownPlugin {
624
624
code = `export default ${ JSON . stringify ( content ) } `
625
625
} else {
626
626
// empty module when it's not a CSS module nor `?inline`
627
- code = ''
627
+ // NOTE: add `export {}` otherwise rolldown treats the module as CJS (https://github.com/rolldown/rolldown/issues/2394)
628
+ code = 'export {}'
628
629
}
629
630
630
631
return {
@@ -641,7 +642,11 @@ export function cssPostPlugin(config: ResolvedConfig): RolldownPlugin {
641
642
let chunkCSS = ''
642
643
// the chunk is empty if it's a dynamic entry chunk that only contains a CSS import
643
644
const isJsChunkEmpty = code === '' && ! chunk . isEntry
644
- let isPureCssChunk = chunk . exports . length === 0
645
+ // NOTE: use this instead of "chunk.exports.length === 0" because of https://github.com/rolldown/rolldown/issues/2395
646
+ let isPureCssChunk =
647
+ opts . format === 'es'
648
+ ? ! / e x p o r t \s + / . test ( code )
649
+ : ! / e x p o r t s (?: \. \w | \[ ) / . test ( code )
645
650
const ids = Object . keys ( chunk . modules )
646
651
for ( const id of ids ) {
647
652
if ( styles . has ( id ) ) {
Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ export default defineConfig({
20
20
'./playground/backend-integration/**/*.spec.[tj]s' , // https://github.com/rolldown/rolldown/issues/2392
21
21
'./playground/dynamic-import/**/*.spec.[tj]s' , // https://github.com/rolldown/rolldown/issues/1843
22
22
'./playground/external/**/*.spec.[tj]s' , // https://github.com/rolldown/rolldown/issues/2041
23
- './playground/glob-import/**/*.spec.[tj]s' , // remove empty CSS generate chunk https://github.com/rolldown/rolldown/issues/1842
24
23
'./playground/lib/**/*.spec.[tj]s' , // umd format
25
24
'./playground/object-hooks/**/*.spec.[tj]s' , // object hook sequential
26
25
'./playground/optimize-deps/**/*.spec.[tj]s' , // https://github.com/rolldown/rolldown/issues/2031
You can’t perform that action at this time.
0 commit comments