A Babel plugin that transforms JavaScript decorators (legacy TC39 stage 1) into simpler, smaller code using modern features like class static blocks, private fields, and WeakMap. Current stable version is 2.3.1, released December 2025, with minor/patch releases every few months. Key differentiators vs @babel/plugin-proposal-decorators: significantly smaller output, avoids transpiling other class features, built-in browser compatibility options. Supports both legacy and loose mode decorators, aims for bug-for-bug compatibility with Babel's legacy decorator transform. Includes a runtime helper for decorator initialization.
npm install decorator-transformsVerified import paths — ran on the pinned version, not inferred.
Shows minimal Babel config with runEarly and runtime import, global runtime import at app entry, and a simple decorated class.
Use 'module:decorator-transforms' or require.resolve('decorator-transforms') in plugins array.Add import 'decorator-transforms/globals' at app entry or set runtime: { import: ... } in config.Remove @babel/plugin-proposal-decorators from plugins when using decorator-transforms.
Set runEarly: false (default) unless you need transpilation of private fields or static blocks.
Use runtime: 'globals' (default) and import 'decorator-transforms/globals' in app.js.
Ensure you have added import 'decorator-transforms/globals' at the very beginning of your entry file.
Use 'module:decorator-transforms' or require.resolve('decorator-transforms') in babel config.Ensure Babel 7.4+ is installed and that @babel/core is a peer dependency.
No dependency data recorded yet.