{"id":21237,"library":"esbuild-plugin-decorator","title":"esbuild-plugin-decorator","description":"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.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/linbudu599/nx-plugins","tags":["javascript","esbuild","ESBuild","decorator","plugin","typescript","swc"],"install":[{"cmd":"npm install esbuild-plugin-decorator","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-decorator","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-decorator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for compiling TypeScript decorators","package":"@swc/core","optional":false},{"reason":"Peer dependency; esbuild-plugin-decorator is a plugin for ESBuild","package":"esbuild","optional":false}],"imports":[{"note":"Default export only. ESBuild plugins are often loaded via ESM default import.","wrong":"const { esbuildPluginDecorator } = require('esbuild-plugin-decorator')","symbol":"esbuildPluginDecorator","correct":"import esbuildPluginDecorator from 'esbuild-plugin-decorator'"},{"note":"The package has a default export. Name your import anything you like.","wrong":"","symbol":"default","correct":"import decoratorPlugin from 'esbuild-plugin-decorator'"},{"note":"Type import for configuration options. Exported as a named type.","wrong":"","symbol":"EsbuildPluginDecoratorOptions","correct":"import type { EsbuildPluginDecoratorOptions } from 'esbuild-plugin-decorator'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport esbuildPluginDecorator from 'esbuild-plugin-decorator';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    esbuildPluginDecorator({\n      tsconfig: './tsconfig.json',\n      decoratorVersion: 'legacy', // 'legacy' | 'tc39'\n    }),\n  ],\n});","lang":"typescript","description":"Shows how to register the decorator plugin with esbuild, specifying the tsconfig path and decorator version (legacy for TypeScript <5.0, tc39 for modern)."},"warnings":[{"fix":"Install @swc/core alongside this plugin: npm install @swc/core","message":"The plugin requires @swc/core to be installed as a peer dependency. Missing it causes a runtime error when decorators are encountered.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Avoid using export default class with decorators; use named exports instead.","message":"The plugin does not handle export default class with decorators correctly; the decorator may not be applied properly in some edge cases.","severity":"gotcha","affected_versions":"0.4.0"},{"fix":"Set decoratorVersion: 'tc39' in plugin options.","message":"The decoratorVersion option defaults to 'legacy' which is deprecated in TypeScript 5.0+. Users should migrate to 'tc39' for future compatibility.","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Set useDefineForClassFields: true in tsconfig.json.","message":"If your tsconfig.json has 'useDefineForClassFields' set to false, the plugin may produce incorrect output. It assumes true.","severity":"gotcha","affected_versions":">=0.4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: npm install @swc/core","cause":"Missing peer dependency @swc/core.","error":"Error: Cannot find module '@swc/core'"},{"fix":"Ensure decoratorVersion is a single string: 'legacy' or 'tc39'.","cause":"Passing multiple decoratorVersion values or conflicting config.","error":"Error: The decorator plugin only supports one decorator version per build"},{"fix":"Use: import esbuildPluginDecorator from 'esbuild-plugin-decorator'","cause":"Importing a named export instead of default.","error":"TypeError: esbuildPluginDecorator is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}