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. - Targets the
ESNextlibrary so you write against the latest language features the V8 isolate supports. - Leaves emit behavior to the selected role so the same runtime works with Wrangler-managed and TypeScript-emitted Workers.
- Layers cleanly after a role preset, keeping runtime concerns separate from build ownership.
Usage
Add the preset after the essentials, strict, and app-role layers.
tsconfig.json
{
"extends": [
"@cbnventures/nova/presets/tsconfig/dx-essentials.json",
"@cbnventures/nova/presets/tsconfig/dx-strict.json",
"@cbnventures/nova/presets/tsconfig/role-app.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. |
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.