Skip to content

Commit e595aeb

Browse files
committed
chore: oops forgot this part
1 parent 4dfd9b6 commit e595aeb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

scripts/rollup/plugin-virtual.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Note: this is implemented as a .js + .d.ts, rather than just .js or .ts,
2+
// so we can use it in both JS scripts without compiling and in TS test files
3+
4+
export default function virtual(code, name = '__virtual__') {
5+
return {
6+
resolveId(id) {
7+
// Don't turn the virtual module into a real file path
8+
if (id === name) return id;
9+
},
10+
load(id) {
11+
if (id === name) return code;
12+
},
13+
};
14+
}

0 commit comments

Comments
 (0)