Skip to content

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

Description

@paoloricciuti

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions