An esbuild plugin that enables TypeScript's emitDecoratorMetadata support by transpiling decorated files with the TypeScript compiler. Version 1.0.3 is the latest and only stable release. It provides a lightweight, regex-based decorator detection and optional caching. Unlike alternatives like ts-jest or tsc compilation, this plugin integrates directly with esbuild's fast bundler, only reverting to tsc for files that contain decorators when emitDecoratorMetadata is enabled. Best suited for projects that need both esbuild's speed and TypeScript decorators with metadata reflection (e.g., NestJS, TypeORM, inversify).
npm install esbuild-plugin-ts-decoratorsVerified import paths — ran on the pinned version, not inferred.
Shows how to set up esbuild with esbuild-plugin-ts-decorators, including plugin options and TypeScript type usage.
If performance is a concern, consider using alternative tools like tsc or ts-jest for decorator-heavy projects, or limit the plugin's scope with esbuild's plugin filters.
Set cache: true in plugin options if you want to avoid re-compiling unchanged decorated files on every build.
Stay updated with plugin releases; consider using a more robust parser (e.g., TypeScript's AST) if regex fails.
Ensure your tsconfig.json has "experimentalDecorators": true and "emitDecoratorMetadata": true.
If a file uses decorators indirectly (e.g., re-exports), it may not be detected; manually include the file or set force: true to transpile all files.
Pass a valid tsconfig option: esbuildDecorators({ tsconfig: 'tsconfig.json' })Ensure esbuildDecorators is the first plugin in the plugins array.
Run npm install esbuild-plugin-ts-decorators --save-dev and verify the import statement: import { esbuildDecorators } from 'esbuild-plugin-ts-decorators'