Skip to content

[Workers] Added workaround for SvelteKit autoconfig types file error - #34177

Merged
irvinebroque merged 1 commit into
cloudflare:productionfrom
neelakolkar-cf:issue-30693-sveltekit-wrangler-types
Oct 10, 2026
Merged

irvinebroque merged 1 commit into
cloudflare:productionfrom
neelakolkar-cf:issue-30693-sveltekit-wrangler-types

Conversation

@neelakolkar-cf

Copy link
Copy Markdown
Contributor

Closes #30693

Summary

Adds a caution to the SvelteKit framework guide. It explains why the first wrangler deploy on an existing SvelteKit project fails with Types file not found at worker-configuration.d.ts, and how to fix it.

Why

When wrangler deploy automatically configures an existing SvelteKit project, it runs sv add sveltekit-adapter=adapter:cloudflare+cfTarget:workers. Since sveltejs/cli#1057, that add-on puts wrangler types --check in front of the build script. Wrangler then runs the build right away, without generating types first. --check fails because worker-configuration.d.ts does not exist yet.

Reproduction with wrangler 4.149.0, sv 1.1.1 and SvelteKit 3:

  1. npx sv create app --template minimal --types ts --no-add-ons
  2. npx wrangler deploy: setup runs, then the build fails with Types file not found at worker-configuration.d.ts
  3. npx wrangler types, then npx wrangler deploy: builds and deploys normally

The proper fix belongs in workers-sdk: autoconfig should run typegen after sv add and before building (packages/autoconfig/src/frameworks/sveltekit.ts).
This caution should be removed once that fix ships.

Documentation checklist

  • Is there a changelog entry (guidelines)? Not needed. This is a docs workaround, not a product change.
  • The change adheres to the documentation style guide.

@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

AI Review

✅ Reviewed ebf641c · 0 findings · incremental

Commands
  • /review Run a review now.
  • /full-review Review the entire PR diff.
  • /disable-auto-review Stop automatic reviews.
  • /rebase Rebase against production.

@irvinebroque irvinebroque 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.

what do we need to do to actually fix this?

@irvinebroque
irvinebroque enabled auto-merge (squash) October 10, 2026 16:49
@neelakolkar-cf

Copy link
Copy Markdown
Contributor Author

what do we need to do to actually fix this?

@irvinebroque Thanks for the quick approval! :)))
The real fix it seems is in workers-sdk autoconfig. In runAutoConfig() (packages/autoconfig/src/run.ts), we write wrangler.jsonc and go straight to the build without generating types. For SvelteKit, sv add (since sveltejs/cli#1057) prepends wrangler types --check to build, so the first build fails because worker-configuration.d.ts doesn't exist yet.

Fix: in run.ts, after the config is saved and before runCommand(buildCommand), run wrangler types (cf workers types for the cf target) for TypeScript projects. It needs to go there, not in frameworks/sveltekit.ts in my opinion, because the final config is only written after configure(). That placement also covers any other framework that adds types --check.

Repro- is in the PR description (wrangler 4.149.0, sv 1.1.1). I'll remove this caution once the fix ships.

@irvinebroque
irvinebroque merged commit 3d09386 into cloudflare:production Oct 10, 2026
11 checks passed
@irvinebroque

Copy link
Copy Markdown
Contributor

Want to make a PR there in workers-sdk?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:workers Related to Workers product size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sveltekit deploy docs not working

2 participants