Skip to main content

Tool - Vite

Align TypeScript with how Vite resolves and transpiles your code, so the compiler type-checks while Vite owns the build output.

Why Use This Preset?

  1. Sets moduleResolution to Bundler so TypeScript resolves imports the same way Vite does.
  2. Allows native TypeScript file extensions in imports used by Vite-loaded configuration modules.
  3. Enables isolatedModules so each file type-checks safely under Vite's per-file transpilation.
  4. Ships browser lib defaults so DOM and ESNext globals are available without extra wiring.
  5. Leaves output ownership to the selected role instead of mixing build policy into a tool preset.
  6. Sits last in the extends chain so its bundler-oriented settings layer cleanly over the other presets.

Usage

Add the preset as the final entry in your tsconfig.json extends chain, after the essentials, strict, role, and runtime 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-browser.json",
    "@cbnventures/nova/presets/tsconfig/tool-vite.json"
  ],
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    },
    "rootDir": "./",
    "types": [
      "vite/client"
    ]
  },
  "include": [
    "./*",
    "./src/**/*"
  ],
  "exclude": [
    "./build/**",
    "./node_modules/**"
  ]
}

What This Preset Configures

The preset sets the following compilerOptions to match Vite's bundler-driven workflow.

SettingValueDescription
allowImportingTsExtensionstrueAccepts explicit .ts, .mts, and .tsx imports in Vite-loaded modules.
isolatedModulestrueEnforces per-file type safety since Vite transpiles each file alone.
lib["DOM", "DOM.Iterable", "ESNext"]Exposes browser DOM APIs and the latest ESNext library features.
module"ESNext"Emits modern ECMAScript module syntax for the bundler to consume.
moduleResolution"Bundler"Resolves imports the way Vite does, including bare and extensionless paths.