oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.87k stars 2.74k forks source link

`bun test` cannot handle SvelteKit's `$env/dynamic/*` imports #10712

Open lackita opened 5 months ago

lackita commented 5 months ago

What version of Bun is running?

1.1.6+e58d67b46

What platform is your computer?

Linux 6.5.0-28-generic x86_64 x86_64

What steps can reproduce the bug?

Create a library in a sveltekit project which includes this import:

import { env } from "$env/dynamic/private";

Add a test that imports this module and run that test, you will see an error like this:

error: Cannot find module "$env/dynamic/private" from "/path/to/repo/src/lib/server/env.ts"

Now, if you import that same module in a +page.server.ts file and load the corresponding page, it should load without issue.

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

Seems like this issue also existed in vitest a while back, but SvelteKit solved the problem with this PR.

Note that I'm also using workspaces in my project, so if the instructions above can't replicate the problem it may be related to that. I don't think so because I can still start the server and use the library that way, but always a possibility.

emilio-toledo commented 21 hours ago

+1