{"id":21224,"library":"esbuild-decorators","title":"@anatine/esbuild-decorators","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/reconbot/esbuild-decorators","tags":["javascript","esbuild","decorators","typescript","experimentalDecorators","emitDecoratorMetadata"],"install":[{"cmd":"npm install esbuild-decorators","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-decorators","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-decorators","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin hooks into esbuild's build process","package":"esbuild","optional":false},{"reason":"Peer dependency; used for transpiling files with decorators","package":"typescript","optional":false}],"imports":[{"note":"Only named export. Default import is not available.","wrong":"import esbuildDecorators from '@anatine/esbuild-decorators'","symbol":"esbuildDecorators","correct":"import { esbuildDecorators } from '@anatine/esbuild-decorators'"},{"note":"CJS require with destructuring because the module exports a named object.","wrong":"const esbuildDecorators = require('@anatine/esbuild-decorators')","symbol":"esbuildDecorators","correct":"const { esbuildDecorators } = require('@anatine/esbuild-decorators')"},{"note":"TypeScript type export for the plugin options interface.","wrong":null,"symbol":"EsbuildDecoratorsOptions","correct":"import type { EsbuildDecoratorsOptions } from '@anatine/esbuild-decorators'"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport { esbuildDecorators } from '@anatine/esbuild-decorators';\n\nasync function main() {\n  await build({\n    entryPoints: ['src/index.ts'],\n    outfile: 'dist/index.js',\n    bundle: true,\n    platform: 'node',\n    target: 'node14',\n    plugins: [\n      esbuildDecorators({\n        tsconfig: './tsconfig.json',\n        cwd: process.cwd(),\n        force: false,\n        tsx: false,\n      }),\n    ],\n  });\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Shows how to integrate the plugin into an esbuild build, passing the tsconfig and optional options."},"warnings":[{"fix":"Use only for projects that require experimental decorators; avoid mixing with other esbuild TypeScript plugins.","message":"This 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.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Review the regex pattern and file an issue if your decorator syntax is not detected.","message":"The plugin uses a regex to detect decorators, which may not match all edge cases (e.g., decorators with complex arguments, multiline decorators). Test thoroughly.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set `force: false` (default) to let the plugin decide which files need tsc.","message":"When `force: true`, all .ts files are transpiled via tsc, which significantly slows down builds. Use only for debugging or small projects.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Import from '@anatine/esbuild-decorators'.","message":"The 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.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `import { esbuildDecorators } from '@anatine/esbuild-decorators'`.","cause":"Using `import esbuildDecorators from 'esbuild-decorators'` instead of named import.","error":"Error: The module 'esbuild-decorators' does not provide a default export"},{"fix":"Install the package as a devDependency and ensure 'typescript' is installed. The package ships types.","cause":"Types are not installed or module resolution is misconfigured.","error":"Error: Could not find a declaration file for module '@anatine/esbuild-decorators'"},{"fix":"Use `const { esbuildDecorators } = require('@anatine/esbuild-decorators')`.","cause":"Using `require('@anatine/esbuild-decorators')` without destructuring.","error":"TypeError: esbuildDecorators is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}