esbuild-plugin-ts

raw JSON →
0.1.1-rev-1.0 verified Fri May 01 auth: no javascript

esbuild-plugin-ts is an esbuild plugin that integrates TypeScript's exotic features, such as type checking, decorator metadata emission, and path alias resolution. Current version is 0.1.1-rev-1.0, released as in-development and not feature complete. It leverages the TypeScript compiler (tsc) under the hood to address esbuild's limitations in handling TypeScript while remaining fast via worker threads. Key differentiators: focuses on bridging gaps for advanced TypeScript features like decorators and path aliases, unlike simpler plugins that only provide basic transpilation.

error Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'esbuild-plugin-ts' imported from ...
cause Package not installed or not in node_modules.
fix
Run npm install esbuild-plugin-ts or yarn add esbuild-plugin-ts.
error TypeError: esbuildPluginTs is not a function
cause Importing wrong export (e.g., using destructured import instead of default).
fix
Use import esbuildPluginTs from 'esbuild-plugin-ts' and call as esbuildPluginTs().
error Error: [esbuild-plguin-ts] Unable to locate tsconfig.json. Ensure you have a tsconfig.json in the project root or provide the path via options.
cause No tsconfig.json found.
fix
Create a tsconfig.json file or pass { tsconfig: 'path/to/tsconfig.json' } in the options.
breaking esbuildPluginTs() may throw if no tsconfig.json is found.
fix Ensure a tsconfig.json exists in the project root, or pass options with a custom tsconfig path.
deprecated The plugin is in-development and not feature complete; features listed as '[ ]' are not yet implemented.
fix Check the README for feature status; do not rely on unimplemented features like path alias resolution or decorator metadata.
gotcha TypeScript worker thread may cause port conflicts if multiple builds run concurrently.
fix Avoid running multiple builds simultaneously, or serialize builds.
gotcha Type errors from tsc are not propagated as esbuild errors; build may succeed even with type errors.
fix Manually check tsc output or use a separate type checking step.
npm install esbuild-plugin-ts
yarn add esbuild-plugin-ts
pnpm add esbuild-plugin-ts

Basic usage of esbuild-plugin-ts to bundle a TypeScript entry point with type checking and advanced transforms.

import { build } from 'esbuild';
import esbuildPluginTs from 'esbuild-plugin-ts';

build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  outfile: 'dist/out.js',
  plugins: [esbuildPluginTs()]
}).catch(() => process.exit(1));