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.

web-framework
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.

Only named export. Default import is not available.

import { esbuildDecorators } from '@anatine/esbuild-decorators'

CJS require with destructuring because the module exports a named object.

const { esbuildDecorators } = require('@anatine/esbuild-decorators')

TypeScript type export for the plugin options interface.

import type { EsbuildDecoratorsOptions } from '@anatine/esbuild-decorators'

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 footguns
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.
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.
gotchaWhen `force: true`, all .ts files are transpiled via tsc, which significantly slows down builds. Use only for debugging or small projects.
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.
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
13 hits · last 30 days
gptbot
4
ahrefsbot
3
claudebot
3
script
1
chatgpt-user
1
Resources