Skip to content

Skip the Cloudflare env loader in SvelteKit vite dev - #1273

Merged
theoephraim merged 1 commit into
mainfrom
fix-sveltekit-cf-dev-loader
Nov 3, 2026
Merged

theoephraim merged 1 commit into
mainfrom
fix-sveltekit-cf-dev-loader

Conversation

@theoephraim

Copy link
Copy Markdown
Member

Fixes #1267.

adapter-cloudflare 8 emulates cloudflare:workers in Node during vite dev, using wrangler's platform proxy env. That env has no __VARLOCK_ENV binding, 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 preview is unaffected since it runs the built output.

The deprecated varlockSvelteKitCloudflarePlugin passed the loader explicitly, which bypassed detection. It now calls varlockVitePlugin({ isCloudflareTarget: true }) so it gets the same behavior, and logs a deprecation warning.

Tests: new sveltekit-v3-cloudflare framework suite (SvelteKit 3 + adapter-cloudflare 8) covering vite 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.

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
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

bumpy-frog

The changes in this PR will be included in the next version bump.

patch Patch releases

  • @varlock/astro-integration 1.4.5 → 1.4.6 (cascade)
  • @varlock/cloudflare-integration 1.6.3 → 1.6.4
  • @varlock/nuxt-integration 0.1.5 → 0.1.6 (cascade)
  • @varlock/vite-integration 1.5.5 → 1.5.6

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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) and pnpm is unavailable (pnpm: command not found); preview and deployed Worker behavior were not runtime-tested.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@pkg-pr-new

pkg-pr-new Bot commented Nov 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

varlock

npm i https://pkg.pr.new/varlock@1273

@varlock/astro-integration

npm i https://pkg.pr.new/@varlock/astro-integration@1273

@varlock/cloudflare-integration

npm i https://pkg.pr.new/@varlock/cloudflare-integration@1273

@varlock/nuxt-integration

npm i https://pkg.pr.new/@varlock/nuxt-integration@1273

@varlock/vite-integration

npm i https://pkg.pr.new/@varlock/vite-integration@1273

@varlock/native-helper-darwin

npm i https://pkg.pr.new/@varlock/native-helper-darwin@1273

@varlock/native-helper-linux-arm64

npm i https://pkg.pr.new/@varlock/native-helper-linux-arm64@1273

@varlock/native-helper-linux-x64

npm i https://pkg.pr.new/@varlock/native-helper-linux-x64@1273

@varlock/native-helper-win32-x64

npm i https://pkg.pr.new/@varlock/native-helper-win32-x64@1273

commit: 3500d1e

@theoephraim
theoephraim merged commit 3134159 into main Nov 3, 2026
34 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: vite dev returns 500 on SvelteKit 3 + adapter-cloudflare 8: "no __VARLOCK_ENV binding found"

1 participant