Skip to content

Commit 7e989a6

Browse files
committed
fix: just bail out
1 parent c7280c1 commit 7e989a6

File tree

3 files changed

+15
-39
lines changed

3 files changed

+15
-39
lines changed

packages/plugin-rsc/src/plugin.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {
4040
import { cjsModuleRunnerPlugin } from './plugins/cjs'
4141
import { evalValue, parseIdQuery } from './plugins/utils'
4242
import { createDebug } from '@hiogawa/utils'
43-
import { scanBuildStrip } from './plugins/scan'
4443

4544
// state for build orchestration
4645
let serverReferences: Record<string, string> = {}
@@ -902,14 +901,28 @@ globalThis.AsyncLocalStorage = __viteRscAyncHooks.AsyncLocalStorage;
902901
]
903902
}
904903

904+
// https://github.com/vitejs/vite/blob/86d2e8be50be535494734f9f5f5236c61626b308/packages/vite/src/node/plugins/importMetaGlob.ts#L113
905+
const importGlobRE = /\bimport\.meta\.glob(?:<\w+>)?\s*\(/g
906+
907+
// During scan build, we strip all code but imports to
908+
// traverse module graph faster and just discover client/server references.
905909
function scanBuildStripPlugin(): Plugin {
906910
return {
907911
name: 'rsc:scan-strip',
908912
apply: 'build',
909913
enforce: 'post',
910914
transform(code, _id, _options) {
911915
if (!isScanBuild) return
912-
const output = scanBuildStrip(code)
916+
917+
// bail out if import.meta.glob
918+
// https://github.com/vitejs/rolldown-vite/issues/373
919+
if (importGlobRE.test(code)) return code
920+
921+
const [imports] = esModuleLexer.parse(code)
922+
const output = imports
923+
.map((e) => e.n && `import ${JSON.stringify(e.n)};\n`)
924+
.filter(Boolean)
925+
.join('')
913926
return { code: output, map: { mappings: '' } }
914927
},
915928
}

packages/plugin-rsc/src/plugins/scan.test.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/plugin-rsc/src/plugins/scan.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)