Skip to content

Detect the Cloudflare adapter with SvelteKit 3 - #1240

Merged
theoephraim merged 2 commits into
dmno-dev:mainfrom
stickerdaniel:fix-sveltekit3-adapter-detection
Oct 28, 2026
Merged

theoephraim merged 2 commits into
dmno-dev:mainfrom
stickerdaniel:fix-sveltekit3-adapter-detection

Conversation

@stickerdaniel

@stickerdaniel stickerdaniel commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

SvelteKit 3 moved the resolved adapter from api.options.kit.adapter to api.options.adapter on vite-plugin-sveltekit-setup. detectSvelteKitCloudflareTarget (added in #827) only read the old path, so on SvelteKit 3 the Workers env loader was never injected and nothing read the __VARLOCK_ENV binding. It now reads both shapes.

With SvelteKit 3.0.1 and @sveltejs/adapter-cloudflare 8.0.0, vite build previously logged no detection notice and emitted an init-only SSR chunk. Now the notice is logged and the chunk reads __VARLOCK_ENV, as with SvelteKit 2.

Adds unit tests for both shapes, and a docs note that SvelteKit 3 only supports the Vite config.

SvelteKit references, to check the shape change:

SvelteKit 3 flattened its resolved config, so the adapter is at api.options.adapter instead of api.options.kit.adapter. The detection only read the old path and never injected the Workers env loader. Check both shapes.

@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 Checked adapter detection, regression tests, documentation, and the patch release entry against SvelteKit's versioned upstream source; all 22 Vite integration tests passed after generating the parser grammar.

  • Adapter detection: Supports SvelteKit 3's api.options.adapter while retaining SvelteKit 2's api.options.kit.adapter and the existing Cloudflare loader behavior.
  • Regression coverage: Exercises loader injection for both configuration shapes and confirms non-Cloudflare adapters remain unaffected.
  • Documentation and release: Clarifies SvelteKit 3's Vite-only configuration and includes a patch release entry for the Vite integration.

Validation used synthetic setup plugins and a mocked loader, not a live SvelteKit 3 build or Workers deployment.

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

@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 Reviewed the delta since 70c5136, verified the setup plugin name against SvelteKit 3.0.1's source, and ran all 24 Vite integration tests successfully.

  • Restricted flattened adapter detection: Required vite-plugin-sveltekit-setup for the SvelteKit 3 adapter shape, preventing unrelated plugins from shadowing detection while preserving the SvelteKit 2 lookup.
  • Added regression coverage: Tested an unrelated top-level adapter preceding SvelteKit and adapter-auto detection with WORKERS_CI=1.

Validation used synthetic setup plugins and a mocked loader, not a live SvelteKit build or Workers deployment.

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

@theoephraim
theoephraim merged commit 0d55ab5 into dmno-dev:main Oct 28, 2026
30 of 31 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.

2 participants