babel-plugin-transform-decorators
Compile class and object decorators to ES5
Last updated 3 years ago by hzoo .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install babel-plugin-transform-decorators 
SYNC missed versions from official npm registry.

babel-plugin-transform-decorators

Compile class and object decorators to ES5

Example

(examples are from proposal)

Simple class decorator

@annotation
class MyClass { }

function annotation(target) {
   target.annotated = true;
}

Class decorator

@isTestable(true)
class MyClass { }

function isTestable(value) {
   return function decorator(target) {
      target.isTestable = value;
   }
}

Class function decorator

class C {
  @enumerable(false)
  method() { }
}

function enumerable(value) {
  return function (target, key, descriptor) {
     descriptor.enumerable = value;
     return descriptor;
  }
}

Installation

npm install --save-dev babel-plugin-transform-decorators

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-decorators"]
}

Via CLI

babel --plugins transform-decorators script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-decorators"]
});

References

Current Tags

  • 6.24.1                                ...           latest (3 years ago)
  • 7.0.0-beta.3                                ...           next (3 years ago)

38 Versions

  • 7.0.0-beta.3                                ...           3 years ago
  • 7.0.0-beta.2                                ...           3 years ago
  • 7.0.0-beta.1                                ...           3 years ago
  • 7.0.0-beta.0                                ...           3 years ago
  • 7.0.0-alpha.20                                ...           3 years ago
  • 7.0.0-alpha.19                                ...           3 years ago
  • 7.0.0-alpha.18                                ...           3 years ago
  • 7.0.0-alpha.17                                ...           3 years ago
  • 7.0.0-alpha.16                                ...           3 years ago
  • 7.0.0-alpha.15                                ...           3 years ago
  • 7.0.0-alpha.14                                ...           3 years ago
  • 7.0.0-alpha.12                                ...           3 years ago
  • 7.0.0-alpha.11                                ...           3 years ago
  • 7.0.0-alpha.10                                ...           3 years ago
  • 7.0.0-alpha.9                                ...           3 years ago
  • 7.0.0-alpha.8                                ...           3 years ago
  • 6.24.1                                ...           3 years ago
  • 7.0.0-alpha.7                                ...           3 years ago
  • 7.0.0-alpha.3                                ...           3 years ago
  • 7.0.0-alpha.1                                ...           3 years ago
  • 6.22.0                                ...           3 years ago
  • 6.13.0                                ...           4 years ago
  • 6.8.0                                ...           4 years ago
  • 6.6.5                                ...           4 years ago
  • 6.6.4                                ...           4 years ago
  • 6.6.0                                ...           4 years ago
  • 6.5.0-1                                ...           4 years ago
  • 6.5.0                                ...           4 years ago
  • 6.4.0                                ...           5 years ago
  • 6.3.13                                ...           5 years ago
  • 6.2.4                                ...           5 years ago
  • 6.1.18                                ...           5 years ago
  • 6.1.17                                ...           5 years ago
  • 6.1.10                                ...           5 years ago
  • 6.1.5                                ...           5 years ago
  • 6.1.4                                ...           5 years ago
  • 6.0.14                                ...           5 years ago
  • 6.0.2                                ...           5 years ago
Downloads
Today 6,804
This Week 6,804
This Month 73,210
Last Day 1,909
Last Week 41,186
Last Month 172,931
Dependencies (5)
Dev Dependencies (1)
Dependents (220)

Copyright 2014 - 2016 © taobao.org |