An ESBuild plugin that enables TypeScript decorator support during bundling. Version 0.4.0 compiles decorators using SWC under the hood, preserving semantics while maintaining fast build speeds. It integrates as an esbuild plugin with no config changes beyond registration. Key differentiators: leverages SWC's stable decorator transform, supports both legacy and TC39 stage 3 decorators, and works alongside other ESBuild plugins. Updated irregularly.
npm install esbuild-plugin-decoratorVerified import paths — ran on the pinned version, not inferred.
Shows how to register the decorator plugin with esbuild, specifying the tsconfig path and decorator version (legacy for TypeScript <5.0, tc39 for modern).
Install @swc/core alongside this plugin: npm install @swc/core
Avoid using export default class with decorators; use named exports instead.
Set decoratorVersion: 'tc39' in plugin options.
Set useDefineForClassFields: true in tsconfig.json.
Run: npm install @swc/core
Ensure decoratorVersion is a single string: 'legacy' or 'tc39'.
Use: import esbuildPluginDecorator from 'esbuild-plugin-decorator'