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 @@ -577,7 +577,8 @@ export function cssPostPlugin(config: ResolvedConfig): RolldownPlugin {
577
577
code = `export default ${ JSON . stringify ( content ) } `
578
578
} else {
579
579
// empty module when it's not a CSS module nor `?inline`
580
- code = ''
580
+ // NOTE: add `export {}` otherwise rolldown treats the module as CJS (https://github.com/rolldown/rolldown/issues/2394)
581
+ code = 'export {}'
581
582
}
582
583
583
584
return {
@@ -596,7 +597,11 @@ export function cssPostPlugin(config: ResolvedConfig): RolldownPlugin {
596
597
let chunkCSS = ''
597
598
// the chunk is empty if it's a dynamic entry chunk that only contains a CSS import
598
599
const isJsChunkEmpty = code === '' && ! chunk . isEntry
599
- let isPureCssChunk = true
600
+ // NOTE: use this instead of "chunk.exports.length === 0" because of https://github.com/rolldown/rolldown/issues/2395
601
+ let isPureCssChunk =
602
+ opts . format === 'es'
603
+ ? ! / e x p o r t \s + / . test ( code )
604
+ : ! / e x p o r t s (?: \. \w | \[ ) / . test ( code )
600
605
const ids = Object . keys ( chunk . modules )
601
606
for ( const id of ids ) {
602
607
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