esbuild-plugin-ts-checker

raw JSON →
1.0.2 verified Fri May 01 auth: no javascript

A plugin for esbuild that runs TypeScript type checking in a separate worker thread, improving build performance by offloading type checks. Works both in build and watch modes. Version 1.0.2 stable, with infrequent updates. Alternatives: esbuild-plugin-typecheck or fork-ts-checker-webpack-plugin for webpack. Installed as a dev dependency alongside esbuild and TypeScript.

error Error: esbuild-plugin-ts-checker requires esbuild ^0.12.0 || ^0.13.0 but found 0.14.x
cause Version mismatch with peer dependency esbuild.
fix
Downgrade esbuild to 0.13.x or check for a newer version of the plugin.
error TypeError: Cannot read properties of undefined (reading 'diagnostics')
cause TypeScript compilation failed or tsconfig.json not found.
fix
Ensure tsconfig.json exists with correct path. Pass 'tsconfig' option explicitly if not default.
gotcha Plugin requires esbuild ^0.12.0 or ^0.13.0. Other versions may break.
fix Use esbuild 0.12.x or 0.13.x. For esbuild 0.14+, check for updated version of plugin.
gotcha In watch mode, type errors are printed but build does not fail. This may hide errors in CI.
fix Set 'failOnError' option to true explicitly, or handle watch mode separately.
gotcha TypeScript version must be >=4.0.0 due to worker thread API usage.
fix Upgrade TypeScript to 4.0.0 or later.
gotcha Plugin uses worker threads; requires Node.js version supporting worker_threads (>=12.0.0).
fix Upgrade Node.js to 12 or later.
npm install esbuild-plugin-ts-checker
yarn add esbuild-plugin-ts-checker
pnpm add esbuild-plugin-ts-checker

Shows minimal esbuild build configuration using the type-checker plugin with bundling for Node.js.

import { build } from 'esbuild';
import { esbuildTsChecker } from 'esbuild-plugin-ts-checker';

await build({
  entryPoints: ['src/index.ts'],
  outdir: 'dist',
  bundle: true,
  platform: 'node',
  target: 'node14',
  sourcemap: 'external',
  plugins: [esbuildTsChecker()],
});
console.log('Build complete with type checking');