-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(env): client/public variables #10848
feat(env): client/public variables #10848
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments
const { clientContent, clientDts } = handleClientModule({ schema, loadedEnv }); | ||
handleDts({ settings, fs, content: clientDts }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are generating code before the load
function; is that correct? Shouldn't we generate code inside load
? Types and client code will be emitted only if the user attempts to use the virtual module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I also think we should be lazy loading the virtual module code. One thing to also check though is if new env vars get picked up across server restarts. As a Vite plugin, it's best to cache or reset the cache with the buildStart
/buildEnd
/config
/configResolved
hooks etc so that we re-compute the env when needed.
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work here @florian-lefebvre!
* feat(env): add schema, types and envField (#10805) * feat(env): add validators (#10827) * feat(env): add vite plugin (#10829) * feat(env): client/public variables (#10848) Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * feat(env): server/public variables (#10881) Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * feat(env): server/secret variables (#10954) Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * fix: import * fix: test * feat: work on jsdoc * feat: more jsdoc * chore: remove todo * feat: fix test error and write changeset * feat: update config reference * feat: apply recommendations from review * feat: rework getEnv/setGetEnv * chore: move tests * fix: rename * fix: dev mode * chore: improve error * feat: add overrideProcessEnv helper * fix: make eslint happy * Update .changeset/poor-berries-occur.md Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> * Update .changeset/poor-berries-occur.md Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> * Update .changeset/poor-berries-occur.md Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> * Update .changeset/poor-berries-occur.md Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> * feat: fix build and address reviews * fix: container api * fix: tests * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/astro/src/@types/astro.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/astro/src/@types/astro.ts * chore: update changeset * feat: address reviews * feat: address Ema's reviews * Update .changeset/poor-berries-occur.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Changes
src/env.d.ts
references are generatedenvField
to the right placeTesting
astro sync
testgetType
Docs
N/A