You can test this stuff by putting that code 👆 into a file like x.js and running bun test ./x.js
What is the expected behavior?
It should resolve the await import("node:test") at runtime so that it's OK that it doesn't exist.
What do you see instead?
jcbhmr@PIG2016:~/Documents/node4web$ cat z.js
const { test } = process.isBun ? await import("bun:test") : await import("node:test")
jcbhmr@PIG2016:~/Documents/node4web$ bun test ./z.js
bun test v1.0.26 (c75e768a)
z.js:
1 | const { test } = process.isBun ? await import("bun:test") : await import("node:test")
^
error: Could not resolve: "node:test". Maybe you need to "bun install"?
at /home/jcbhmr/Documents/node4web/z.js:1:74
0 pass
1 fail
Ran 1 tests across 1 files. [32.00ms]
jcbhmr@PIG2016:~/Documents/node4web$ cat z.js
const { test } = process.isBun ? await import("bun:test") : await import(String("node:test"))
jcbhmr@PIG2016:~/Documents/node4web$ bun test ./z.js
bun test v1.0.26 (c75e768a)
z.js:
0 pass
0 fail
Ran 0 tests across 1 files. [19.00ms]
What version of Bun is running?
1.0.26+c75e768a6
What platform is your computer?
Linux 4.4.0-19041-Microsoft x86_64 x86_64
What steps can reproduce the bug?
I want to conditionally import something. Like this:
...however this fails. I think it's due to early resolution of
node:test
which should NOT be resolved until runtime.As evidence to support that it's something happening before runtime: this works:
You can test this stuff by putting that code 👆 into a file like x.js and running
bun test ./x.js
What is the expected behavior?
It should resolve the
await import("node:test")
at runtime so that it's OK that it doesn't exist.What do you see instead?
Additional information
No response