sveltejs / sveltejs/cli

Cloudflare Project fails to build if a previously build output is in the `.sveltekit` folder

Open
#1,096 3 comments 1 reaction 0 assignees View on GitHub

A pull request for this has already been merged.

  • #1098 by @teemingc — merged
pkg:create
Dominant language
TypeScript
Stars
506
Forks
107
Avg merge
5d 15h
Merged PRs (30d)
28

Description

Since we do wrangler types --check before building when a cloudflare project is built locally the wrangler types generation changes if the .sveltekit folder has the build output inside.

BEFORE BUILD

/* eslint-disable */
// Generated by Wrangler by running `wrangler types` (hash: 4f9fe9ddb2ea1e2c41e1be5910da8551)
// Runtime types generated with workerd@1.20260518.1 2026-05-20 nodejs_als
interface __BaseEnv_Env {
	ASSETS: Fetcher;
}
declare namespace Cloudflare {
	interface Env extends __BaseEnv_Env {}
}
interface Env extends __BaseEnv_Env {}

// Begin runtime types
/*! *****************************************************************************
Copyright (c) Cloudflare. All rights reserved.
Copyright (c) Microsoft Corporation. All rights reserved.

AFTER BUILD

/* eslint-disable */
// Generated by Wrangler by running `wrangler types` (hash: c2abdaaa333fde981ecf28696abe73c4)
// Runtime types generated with workerd@1.20260518.1 2026-05-20 nodejs_als
interface __BaseEnv_Env {
	ASSETS: Fetcher;
}
declare namespace Cloudflare {
	interface GlobalProps {
		mainModule: typeof import("./.svelte-kit/cloudflare/_worker");
	}
	interface Env extends __BaseEnv_Env {}
}
interface Env extends __BaseEnv_Env {}

// Begin runtime types
/*! *****************************************************************************
Copyright (c) Cloudflare. All rights reserved.
Copyright (c) Microsoft Corporation. All rights reserved.

as you can see there's this extra part

/* eslint-disable */
// Generated by Wrangler by running `wrangler types` (hash: c2abdaaa333fde981ecf28696abe73c4)
// Runtime types generated with workerd@1.20260518.1 2026-05-20 nodejs_als
interface __BaseEnv_Env {
	ASSETS: Fetcher;
}
declare namespace Cloudflare {
+	interface GlobalProps {
+		mainModule: typeof import("./.svelte-kit/cloudflare/_worker");
+	}
	interface Env extends __BaseEnv_Env {}
}
interface Env extends __BaseEnv_Env {}

// Begin runtime types
/*! *****************************************************************************
Copyright (c) Cloudflare. All rights reserved.
Copyright (c) Microsoft Corporation. All rights reserved.

Since --check runs the generation and checks with the old one this means that

pnpm gen
pnpm build
pnpm build

will result in the second build to fail.

Even worse, if you regenerate the types and then push the build will break the deployment because the build output will not be present.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in a Cloudflare project with pnpm gen, two successive pnpm build runs, and a deployment after regenerating types. Inspect the build flow around wrangler types --check and the .sveltekit output; done means repeated builds and deployment no longer depend on generated output already being present.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.