An esbuild plugin that enables TypeScript's `emitDecoratorMetadata` option for decorators, generating metadata for `reflect-metadata`. Current version 0.2.3 requires esbuild ^0.14.29 to ^0.25.0. It rewrites and improves upon the original esbuild-decorators package, fixing broken source maps and adding worker-thread support for parallel transpilation. Supports both ESM and CommonJS, ships TypeScript types. Key differentiators: correct source map handling, optional workers for performance, and support for `.tsx` files. Best alternative to using `tsc` for decorator metadata in esbuild.
npm install esbuild-plugin-emit-decorator-metadataNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic esbuild build configuration using the plugin with automatic worker threads.
Enable workers option: `workers: 'auto'` or `workers: true`. Also ensure `tsconfig` path is correct to avoid repeated resolution.
Add `tsx: true` to the plugin options: `{ tsconfig: '...', tsx: true }`.Use it only for debugging; prefer letting esbuild handle caching.
Set `sourceRoot: resolve(process.cwd(), 'src')` in esbuild config.
If you want to disable workers, explicitly set `workers: false`.
npm install -D esbuild-plugin-emit-decorator-metadata
Use named import: import { esbuildEmitDecoratorMetadata } from 'esbuild-plugin-emit-decorator-metadata'Ensure tsconfig path is absolute and valid: esbuildEmitDecoratorMetadata({ tsconfig: resolve(__dirname, 'tsconfig.json') })Add to tsconfig.json: { "compilerOptions": { "experimentalDecorators": true, "emitDecoratorMetadata": true } }