Skip to content

Commit 5aba622

Browse files
committed
fix: keep import.meta.glob with side effect
1 parent 3ec82ab commit 5aba622

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export default "foo";
1616
expect(await transformScanBuildStrip(input)).toMatchInlineSnapshot(`
1717
"import "a";
1818
import "b";
19-
import.meta.glob("d", {
19+
console.log(import.meta.glob("d", {
2020
query: "?e",
21-
})
21+
}));
2222
"
2323
`)
2424
})

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export async function transformScanBuildStrip(code: string): Promise<string> {
2929
node.callee.property.type === 'Identifier' &&
3030
node.callee.property.name === 'glob'
3131
) {
32-
output += code.slice(node.start, node.end) + '\n'
32+
const importMetaGlob = code.slice(node.start, node.end)
33+
output += `console.log(${importMetaGlob});\n`
3334
}
3435
},
3536
})

0 commit comments

Comments
 (0)