Repository navigation
Skip the Cloudflare env loader in SvelteKit vite dev - #1273
Merged
Merged
Conversation
adapter-cloudflare 8 emulates cloudflare:workers in Node during vite dev with wrangler's platform proxy env, which has no __VARLOCK_ENV binding, so the injected loader threw on every SSR request. SvelteKit dev SSR runs in Node and uses varlock's normal load flow, so the loader is now only injected into builds. The deprecated varlockSvelteKitCloudflarePlugin goes through the same detection and logs a deprecation warning. Adds a SvelteKit 3 + adapter-cloudflare 8 framework test suite. Fixes #1267
Contributor
|
The changes in this PR will be included in the next version bump.
|
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes across the full PR, including loader initialization, the deprecated wrapper, and regression coverage.
- Dev loader guard: Skips SvelteKit Cloudflare loader auto-injection for
serve, retaining build-time injection and the normal Node env-loading flow. - Deprecated wrapper: Routes
varlockSvelteKitCloudflarePlugin()through shared detection and emits a once-only deprecation warning. - Regression coverage: Adds SvelteKit 3 / adapter-cloudflare 8 dev, build, legacy-wrapper, and prerender scenarios, plus unit coverage for both SvelteKit config shapes.
- Validation: Workspace builds and all 82 Vite/Cloudflare integration tests passed. Upstream source confirms preview loads built server output. The new framework suite could not run locally because its standalone dependencies are absent (
vitest: command not found) andpnpmis unavailable (pnpm: command not found); preview and deployed Worker behavior were not runtime-tested.
gpt-6.1-sol | 𝕏
varlock
@varlock/astro-integration
@varlock/cloudflare-integration
@varlock/nuxt-integration
@varlock/vite-integration
@varlock/native-helper-darwin
@varlock/native-helper-linux-arm64
@varlock/native-helper-linux-x64
@varlock/native-helper-win32-x64
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #1267.
adapter-cloudflare 8 emulates
cloudflare:workersin Node duringvite dev, using wrangler's platform proxy env. That env has no__VARLOCK_ENVbinding, so the Workers env loader (injected on SvelteKit 3 since #1240) hit the missing-binding error from #1236 on every SSR request.SvelteKit's dev SSR runs in Node and loads env through varlock's normal flow, so the vite plugin now only injects the loader into builds.
vite previewis unaffected since it runs the built output.The deprecated
varlockSvelteKitCloudflarePluginpassed the loader explicitly, which bypassed detection. It now callsvarlockVitePlugin({ isCloudflareTarget: true })so it gets the same behavior, and logs a deprecation warning.Tests: new
sveltekit-v3-cloudflareframework suite (SvelteKit 3 + adapter-cloudflare 8) coveringvite dev, build, a fully prerendered build, and the deprecated plugin in dev and build. Without the fix its dev scenarios fail with the 500 from the issue.