Skip to content

fix(adapter-cloudflare): wrangler types in check/build scripts#1057

Merged
jycouet merged 2 commits intomainfrom
skip-generating-wrangler-types-when-building-for-d
Apr 10, 2026
Merged

fix(adapter-cloudflare): wrangler types in check/build scripts#1057
jycouet merged 2 commits intomainfrom
skip-generating-wrangler-types-when-building-for-d

Conversation

@jycouet
Copy link
Copy Markdown
Contributor

@jycouet jycouet commented Apr 8, 2026

Closes #872

Description

  • wrangler types are no more gitignored
  • use --check flag for wrangler types in check/build scripts

Checklist

  • Update snapshots (if applicable)
  • Add a changeset (if applicable)
  • Allow maintainers to edit this PR
  • I care about what I'm doing, no matter the tool I use (Notepad, Sublime, VSCode, AI...)

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: 693967b

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

This PR includes changesets to release 1 package
Name Type
sv Patch

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 8, 2026

Open in StackBlitz

npx https://pkg.pr.new/svelte-migrate@1057
npx https://pkg.pr.new/sv@1057
npx https://pkg.pr.new/@sveltejs/sv-utils@1057

commit: 693967b

@svelte-docs-bot
Copy link
Copy Markdown

@jycouet jycouet merged commit 9520b3b into main Apr 10, 2026
8 checks passed
@jycouet jycouet deleted the skip-generating-wrangler-types-when-building-for-d branch April 10, 2026 08:53
@github-actions github-actions bot mentioned this pull request Apr 10, 2026
@petebacondarwin
Copy link
Copy Markdown

This actually breaks the create-cloudflare ecosystem tests for SvelteKit:

https://github.com/cloudflare/workers-sdk/actions/runs/24253310618/job/70830164771?pr=13330#step:8:627

The --check requires that the types had previously been generated.

@jycouet
Copy link
Copy Markdown
Contributor Author

jycouet commented Apr 10, 2026

:( can't look right now
It's because types are not commited ?
Can you provide what scripts do you suggest ?

@petebacondarwin
Copy link
Copy Markdown

When the project is first created no typings have been generated - but now running npm run build will fail.
This --check command is designed to fail if the types are out of date, perhaps in CI jobs where you want to ensure that the checked in types are accurate.

But in this case I would argue that you really just want to run wrangler types without the --check to just generate types as part of the build.

@jycouet
Copy link
Copy Markdown
Contributor Author

jycouet commented Apr 10, 2026

In a "normal" case don't you want to break the build if types are out-of-date ?

@petebacondarwin
Copy link
Copy Markdown

OK, so I see that you stopped generating it automatically due to the time that can take (although I believe that we should check the hash stored in the file and not re-run the generation if it has not changed so should be super fast in that case).

Because of that it is necessary to ensure that you have run pnpm run gen at least once before you run pnpm run build. In this case, we can change Wrangler's autoconfig setup to run this as part of setting up a project for Cloudflare.

But I would argue that if things are working correctly, there should be very little cost to running wrangler types regularly. In which case you don't need to run the --check command and will not see any errors.

@jycouet
Copy link
Copy Markdown
Contributor Author

jycouet commented Apr 10, 2026

All I would like is:

  • Best practice from expert
  • Easy onboarding for new users
    (unfortunately, I'm not a cloudflare user today)

What's the normal way to work ? Generate often ? Break build ? Break check ? Never break ?

Auto generating at build time would silence potential issue later at runtime, no ?

We can do everything, we just need to decide.

@petebacondarwin
Copy link
Copy Markdown

We fixed it in our CI tests by running the type generation before running the build. If your users are happy with this flow then it's fine by us.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skip generating wrangler types when building for deployment

2 participants