Skip to content

Commit 10958fc

Browse files
committed
chore: make glob-import test pass with workarounds
1 parent b5b5fb0 commit 10958fc

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
@@ -577,7 +577,8 @@ export function cssPostPlugin(config: ResolvedConfig): RolldownPlugin {
577577
code = `export default ${JSON.stringify(content)}`
578578
} else {
579579
// 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 {}'
581582
}
582583

583584
return {
@@ -596,7 +597,11 @@ export function cssPostPlugin(config: ResolvedConfig): RolldownPlugin {
596597
let chunkCSS = ''
597598
// the chunk is empty if it's a dynamic entry chunk that only contains a CSS import
598599
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+
? !/export\s+/.test(code)
604+
: !/exports(?:\.\w|\[)/.test(code)
600605
const ids = Object.keys(chunk.modules)
601606
for (const id of ids) {
602607
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)