Registry / esbuild-plugin-decorator

esbuild-plugin-decorator

JSON →
library0.4.0jsnpmunverified

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.

Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Default export only. ESBuild plugins are often loaded via ESM default import.

import esbuildPluginDecorator from 'esbuild-plugin-decorator'

The package has a default export. Name your import anything you like.

import decoratorPlugin from 'esbuild-plugin-decorator'

Type import for configuration options. Exported as a named type.

import type { EsbuildPluginDecoratorOptions } from 'esbuild-plugin-decorator'

Shows how to register the decorator plugin with esbuild, specifying the tsconfig path and decorator version (legacy for TypeScript <5.0, tc39 for modern).

import esbuild from 'esbuild'; import esbuildPluginDecorator from 'esbuild-plugin-decorator'; await esbuild.build({ entryPoints: ['src/index.ts'], bundle: true, outfile: 'dist/bundle.js', plugins: [ esbuildPluginDecorator({ tsconfig: './tsconfig.json', decoratorVersion: 'legacy', // 'legacy' | 'tc39' }), ], });
Debug
Known footguns
gotchaThe plugin requires @swc/core to be installed as a peer dependency. Missing it causes a runtime error when decorators are encountered.
gotchaThe plugin does not handle export default class with decorators correctly; the decorator may not be applied properly in some edge cases.
deprecatedThe decoratorVersion option defaults to 'legacy' which is deprecated in TypeScript 5.0+. Users should migrate to 'tc39' for future compatibility.
gotchaIf your tsconfig.json has 'useDefineForClassFields' set to false, the plugin may produce incorrect output. It assumes true.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
16 hits · last 30 days
gptbot
4
bingbot
3
ahrefsbot
3
claudebot
3
script
1
Resources