-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$env/dynamic/private not getting loaded by vitest and vite-node #6225
Comments
Ah, I think you may be hosed here. Dynamic vars are populated by the adapter calling |
It sounds like |
I wonder if there's a simple way to allow testing frameworks to populate it, similar to how |
I haven't used |
But we're already populating it in |
We're initialising it in dev... kit/packages/kit/src/vite/dev/index.js Lines 275 to 277 in 26cdad6
...but I'm suggesting that we actually populate this module instead of re-exporting the kit/packages/kit/src/core/env.js Lines 27 to 30 in 26cdad6
It feels there might be some timing issues that could be resolved with this approach? Not sure |
Interesting. I'm going to self-assign this and see what I can do... |
@benmccann I can confirm that the same thing is happening with |
For me, I find that Edit: I tried |
I am also facing the same issue on windows. |
|
Sorry, yes it is an empty object. |
Describe the bug
Context
This is a followup to #5886. I began using
vite-node
in order to make my SvelteKit code (which depends on Vite's transforms and plugins) importable to backend/database/sysadmin-related scripts. In particular, I need access to the$env
store from my shared code. Running my backend scripts withvite-node
correctly populates$env/static/private
for those scripts 🙌Problem
HOWEVER, confusingly
$env/dynamic/private
is not getting populated throughvite-node
. It ends up being an empty object at runtime even though my.env
file is set up correctly.$env/dynamic/private
is getting properly populated when I run my sveltekit app throughvite dev
though.Reproduction
See my stackblitz. To prove that my env setup is correct, I am serving both static and dynamic env vars from my page endpoint, and rendering on the page (not a "realistic" example, I only want to show that my .env is hooked up correctly). Now, to show the actual bug, run
npm run bug
. This goes throughvite-node
. The static env is printing BUT NOT the dynamic env.I'm not sure if this is a sveltekit or vite-node issue. The vite config knows about the sveltekit plugin, so it should be able to load sveltekit's stores.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-9six26?file=src%2Froutes%2F%2Bpage.svelte,src%2Froutes%2F%2Bpage.server.js,.env,package.json,bug.js&terminal=dev
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: