Registry / web-framework / esbuild-decorators

esbuild-decorators

JSON →
library1.0.0jsnpmunverified

An esbuild plugin for TypeScript decorator metadata (emitDecoratorMetadata and experimentalDecorators). Current stable version 1.0.0, maintained on GitHub by reconbot. It handles the tsconfig setting `emitDecoratorMetadata: true` by inspecting .ts files for decorators and transpiling them with the TypeScript compiler, since esbuild does not natively support TypeScript experimental decorators. Releases are infrequent; the plugin is a fork of the anatine organization's esbuildnx plugin with fixed peer dependencies and ESM/CJS module support. Alternatives include `esbuild-plugin-decorator` and `esbuild-decorators-loader`, but this package focuses on simplicity and direct tsconfig integration.

npm install esbuild-decorators
INSTALL
IMPORT
SIG · ESBUILD-DECORATORS
E
esbuild-decorators
web-frameworkjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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.

esbuildDecorators
import { esbuildDecorators } from '@anatine/esbuild-decorators'
import esbuildDecorators from '@anatine/esbuild-decorators'
Only named export. Default import is not available.
esbuildDecorators
const { esbuildDecorators } = require('@anatine/esbuild-decorators')
const esbuildDecorators = require('@anatine/esbuild-decorators')
CJS require with destructuring because the module exports a named object.
EsbuildDecoratorsOptions
import type { EsbuildDecoratorsOptions } from '@anatine/esbuild-decorators'
TypeScript type export for the plugin options interface.

Shows how to integrate the plugin into an esbuild build, passing the tsconfig and optional options.

import { build } from 'esbuild'; import { esbuildDecorators } from '@anatine/esbuild-decorators'; async function main() { await build({ entryPoints: ['src/index.ts'], outfile: 'dist/index.js', bundle: true, platform: 'node', target: 'node14', plugins: [ esbuildDecorators({ tsconfig: './tsconfig.json', cwd: process.cwd(), force: false, tsx: false, }), ], }); } main().catch(console.error);
Debug
Known issues
breakingThis plugin overrides esbuild's TypeScript handling; files with decorators are transpiled by tsc, not esbuild, which breaks bundling speed and may cause mismatches in module resolution.
fix
Use only for projects that require experimental decorators; avoid mixing with other esbuild TypeScript plugins.
affects: >=0.0.0
gotchaThe plugin uses a regex to detect decorators, which may not match all edge cases (e.g., decorators with complex arguments, multiline decorators). Test thoroughly.
fix
Review the regex pattern and file an issue if your decorator syntax is not detected.
affects: >=0.0.0
gotchaWhen `force: true`, all .ts files are transpiled via tsc, which significantly slows down builds. Use only for debugging or small projects.
fix
Set `force: false` (default) to let the plugin decide which files need tsc.
affects: >=0.0.0
deprecatedThe package name `esbuild-decorators` is used by the npm registry but the import is from `@anatine/esbuild-decorators`. The original `esbuild-decorators` package may be abandoned.
fix
Import from '@anatine/esbuild-decorators'.
affects: >=1.0.0
Errors
Common errors & fixes
Error: The module 'esbuild-decorators' does not provide a default export
Using `import esbuildDecorators from 'esbuild-decorators'` instead of named import.
fix
Use `import { esbuildDecorators } from '@anatine/esbuild-decorators'`.
Error: Could not find a declaration file for module '@anatine/esbuild-decorators'
Types are not installed or module resolution is misconfigured.
fix
Install the package as a devDependency and ensure 'typescript' is installed. The package ships types.
TypeError: esbuildDecorators is not a function
Using `require('@anatine/esbuild-decorators')` without destructuring.
fix
Use `const { esbuildDecorators } = require('@anatine/esbuild-decorators')`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency; plugin hooks into esbuild's build process
typescriptrequiredPeer dependency; used for transpiling files with decorators
Agent activity
3 hits · last 30 days
node
2
Resources
esbuild-decorators — npm install esbuild-decorators · libregistry