cloudflare / cloudflare/workers-sdk

wrangler types emits mainModule pointing to .svelte-kit build output, breaking svelte-check

Open
#14,181 3 comments 1 reaction 2 assignees Claimed by @MattieTK View on GitHub
feature:types package:wrangler
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
186

Description

### What versions & operating system are you using?

Wrangler v4.x (latest), Node v22, macOS

### Please provide a link to a minimal reproduction

https://github.com/Sillyvan/wrangler-types-svelte

### Describe the Bug

Repro is super easy in general.
npm create cloudflare@latest -- my-svelte-app --framework=svelte
cd my-svelte-app
npm run build (important!)
npx wrangler types
npm run check

At some point a wrangler update added functionality to wrangler types, which have downsides to sveltekit and maybe other frameworks. I think this PR caused this issue https://github.com/cloudflare/workers-sdk/pull/10676

**Disclamer: Ai written but seems to describe it better than i can**
wrangler types emits a Cloudflare.GlobalProps interface with a mainModule field typed as typeof import("./.svelte-kit/cloudflare/_worker").
Because SvelteKit's build output lives under .svelte-kit/, svelte-check (and tsc) follows that import() type reference and attempts to type-check generated code inside .svelte-kit/cloudflare/. This fails with various errors since the generated output isn't meant to be checked by the user's TS project.
Example generated worker-configuration.d.ts:
declare namespace Cloudflare {
interface GlobalProps {
mainModule: typeof import("./.svelte-kit/cloudflare/_worker");
}
}
**Expected Behavior**
wrangler types should either:
1. Detect that the resolved entrypoint lives inside a build-output directory (e.g. .svelte-kit/, .next/, dist/) and skip emitting mainModule for it, or
2. Provide a CLI flag (e.g. --no-global-props / --no-main-module) to suppress GlobalProps emission so frameworks can recommend it.

### Please provide any relevant error logs

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.