Registry / devops / esbuild-plugin-decorators

esbuild-plugin-decorators

JSON →
library0.0.3jsnpmunverified

esbuild-plugin-decorators (v0.0.3) is an esbuild plugin that enables support for experimental ECMAScript decorators. It patches the esbuild build process to transform decorators using the TypeScript compiler API. This plugin is intended for projects that rely on legacy decorator syntax (e.g., from TypeScript's experimentalDecorators or Babel) and need to bundle with esbuild, which does not natively support decorators. The plugin is minimal and has no dependencies beyond esbuild and TypeScript. However, it is experimental and not actively maintained; the latest version (0.0.3) was released in early 2023. Compared to alternatives like esbuild-plugin-babel or esbuild-plugin-typescript-decorators, this one is a lightweight wrapper but lacks comprehensive error handling and documentation. Use with caution in production.

npm install esbuild-plugin-decorators
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-DEC
E
esbuild-plugin-decorators
devopsjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import decoratorsPlugin from 'esbuild-plugin-decorators'
const decoratorsPlugin = require('esbuild-plugin-decorators')
Package exports a default function. ESM or CJS both work but default import is cleanest.
decoratorsPlugin
import decoratorsPlugin from 'esbuild-plugin-decorators'
import { decoratorsPlugin } from 'esbuild-plugin-decorators'
Symbol is default export, not named.
apply decorators
esbuild.build({ plugins: [decoratorsPlugin()] })
esbuild.build({ plugins: [decoratorsPlugin] })
Must call the function to create plugin instance.

Shows how to bundle TypeScript with experimental decorators using esbuild and the plugin.

import esbuild from 'esbuild'; import decoratorsPlugin from 'esbuild-plugin-decorators'; await esbuild.build({ entryPoints: ['src/index.ts'], outfile: 'dist/bundle.js', bundle: true, plugins: [decoratorsPlugin()], tsconfig: './tsconfig.json', // ensure experimentalDecorators: true });
Debug
Known issues
gotchaPlugin requires esbuild to be installed as a peer dependency. Not auto-installed.
fix
Install esbuild: npm install esbuild
affects: >=0.0.0
gotchaPlugin requires TypeScript compiler API (typescript package) for transformation. Ensure tsconfig has experimentalDecorators: true.
fix
Install typescript: npm install typescript; set experimentalDecorators in tsconfig.json
affects: >=0.0.0
deprecatedThe plugin is currently at version 0.0.3 with no updates since 2023. It may not work with newer esbuild versions.
fix
Consider using esbuild-plugin-babel or esbuild-plugin-typescript-decorators as more maintained alternatives.
affects: <=0.0.3
gotchaThe plugin does not handle source maps properly; decorator-transformed code may have incorrect source mappings.
fix
If source maps are important, consider a plugin that integrates Babel instead.
affects: >=0.0.0
gotchaOnly works with ES modules (import/export). Does not support CommonJS modules for the input files.
fix
Ensure your entry points use ES module syntax.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-plugin-decorators'
Package not installed
fix
npm install esbuild-plugin-decorators
Error: Decorators are not enabled. Set 'experimentalDecorators': true in tsconfig.json
TypeScript decorator option not enabled
fix
Add "experimentalDecorators": true to tsconfig.json compilerOptions
TypeError: decoratorsPlugin is not a function
Imported default incorrectly (e.g., destructured as named export)
fix
Use import decoratorsPlugin from 'esbuild-plugin-decorators' (default import)
Plugin error: esbuild version mismatch
Incompatible esbuild version (plugin requires esbuild >=0.10)
fix
Update esbuild to version >=0.10 with npm update esbuild
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency: required to use as plugin
typescriptoptionalpeer dependency: used to transpile decorators
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-decorators — npm install esbuild-plugin-decorators · libregistry