Skip to content

Commit 9b3e10c

Browse files
committed
chore: make glob-import test pass with workarounds
1 parent 4b5152f commit 9b3e10c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/vite/src/node/plugins/css.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,8 @@ export function cssPostPlugin(config: ResolvedConfig): RolldownPlugin {
624624
code = `export default ${JSON.stringify(content)}`
625625
} else {
626626
// 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 {}'
628629
}
629630

630631
return {
@@ -641,7 +642,11 @@ export function cssPostPlugin(config: ResolvedConfig): RolldownPlugin {
641642
let chunkCSS = ''
642643
// the chunk is empty if it's a dynamic entry chunk that only contains a CSS import
643644
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+
? !/export\s+/.test(code)
649+
: !/exports(?:\.\w|\[)/.test(code)
645650
const ids = Object.keys(chunk.modules)
646651
for (const id of ids) {
647652
if (styles.has(id)) {

vitest.config.e2e.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default defineConfig({
2020
'./playground/backend-integration/**/*.spec.[tj]s', // https://github.com/rolldown/rolldown/issues/2392
2121
'./playground/dynamic-import/**/*.spec.[tj]s', // https://github.com/rolldown/rolldown/issues/1843
2222
'./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
2423
'./playground/lib/**/*.spec.[tj]s', // umd format
2524
'./playground/object-hooks/**/*.spec.[tj]s', // object hook sequential
2625
'./playground/optimize-deps/**/*.spec.[tj]s', // https://github.com/rolldown/rolldown/issues/2031

0 commit comments

Comments
 (0)