Runtime - Cloudflare Workers
Configure TypeScript for the Cloudflare Workers edge runtime by pairing ESNext modules with bundler resolution while leaving the actual build to Wrangler.
Why Use This Preset?
- Sets
ESNextmodules withBundlerresolution so imports resolve the way Wrangler and esbuild expect. - Enables
isolatedModulesso each file type-checks independently, matching how the bundler transpiles your Worker. - Sets
noEmitso TypeScript checks types only and lets Wrangler own the output, avoiding duplicate JavaScript on disk. - Targets the
ESNextlibrary so you write against the latest language features the V8 isolate supports. - Layers cleanly after
dx-essentialsanddx-strict, keeping runtime concerns separate from your strictness baseline.
Usage
Add the preset to the extends array of your tsconfig.json, after the essentials and strict layers.
tsconfig.json
{
"extends": [
"@cbnventures/nova/presets/tsconfig/dx-essentials.json",
"@cbnventures/nova/presets/tsconfig/dx-strict.json",
"@cbnventures/nova/presets/tsconfig/runtime-cloudflare-workers.json"
]
}
What This Preset Configures
This preset sets the following compilerOptions.
| Setting | Value | Description |
|---|---|---|
isolatedModules | true | Type-checks each file on its own so the bundler can transpile files in isolation. |
lib | ["ESNext"] | Exposes the latest ECMAScript APIs without bundling any DOM type definitions. |
module | ESNext | Emits modern ECMAScript module syntax for the bundler to consume. |
moduleResolution | Bundler | Resolves imports the way a bundler does, matching the Wrangler build pipeline. |
noEmit | true | Runs type-checking only and leaves JavaScript output to Wrangler. |
info
The lib array replaces the parent's value rather than merging with it, so this preset deliberately omits any DOM or WebWorker libraries that a Worker isolate does not provide.
Related
- Review the layering order in TSConfig Best Practices.
- See how presets compose end to end in the Presets Overview.