Skip to main content

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?

  1. Sets ESNext modules with Bundler resolution so imports resolve the way Wrangler and esbuild expect.
  2. Enables isolatedModules so each file type-checks independently, matching how the bundler transpiles your Worker.
  3. Targets the ESNext library so you write against the latest language features the V8 isolate supports.
  4. Leaves emit behavior to the selected role so the same runtime works with Wrangler-managed and TypeScript-emitted Workers.
  5. 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
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.

SettingValueDescription
isolatedModulestrueType-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.
moduleESNextEmits modern ECMAScript module syntax for the bundler to consume.
moduleResolutionBundlerResolves 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.