-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
breaking: serve public env dynamically, prevent use of dynamic env vars during prerendering #11277
Conversation
🦋 Changeset detectedLatest commit: d4f7ce2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I just realized that the adapter-static case is a bit weird. So far we had minors for all the adapters to tell "hey we support SvelteKit 2.0 as well". adapter-static should also get that treatment for the current version, but that is swallowed by this major bump now. We should create a minor release for adapter-static from master to circumvent that. |
Is there much value in an |
True, if someone upgrades to SvelteKit 2 they might as well upgrade to adapter-static v3. We should add that to the migration script though (auto-bump the adapter-static version) |
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.
If you want to do the _app
change (and if it's easy) feel free to do so, else I think this is good to merge.
I think this might be incorrect. Even with prerendering disabled it now prevents any My specific use-case is using the The The build initially compiles OK but then errors at the pre-render stage even with pre-rendering disabled: +layout.server.ts: export const prerender = false Build output:
It's possible to workaround it by adding tests for Scratch that: I think it was all down to me accessing it outside of the |
@CaptainCodeman this does seem to be an issue, see #11341. was there a workaround? if so, could you share it in #11341 perhaps? I did not quite understand the |
Fixes #10008. This does two things:
$env/dynamic/public
while prerendering (use$env/static/public
instead)$env/dynamic/public
from a new dynamically rendered/_env.js
module, instead of populating it with stale build-time valuesTODO:
%sveltekit.env.PUBLIC_WHATEVER%
to continue working (seems reasonable that this would be an exception to the 'you can't use dynamic public env vars during prerendering' rule)$env/dynamic/private
during prerendering_env.js
when prerendering if we detect that$env/dynamic/public
is used somewhere in the app_env.js
configurable, viaconfig.kit.env.publicModule
adapter-static
(and other adapters, if they want) to generate the_env.js
module at build timePlease don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.