babel-plugin-remove-decorators

0.1.1 • Public • Published

babel-plugin-remove-decorators

A babel plugin that removes all decorators from the code. This is useful for testing purposes. It allows you to unit test the code that has decorators attached to it.

Example

Turns this:

function classDec (){};
function methodDec (){};
 
@classDec
class DecoratedClass {
    @methodFoo(true)
    method() { }
}

into this:

function classDec (){};
function methodDec (){};
 
class DecoratedClass {
    method() { }
}

Usage

Install via NPM

$ npm install --save-dev babel-plugin-remove-decorators

See Babel's documentation on plugins.

! Ensure that you have ES7 decorator support enabled.

! You need to use the plugin with the before position specifier.

.babelrc example:

{
  "optional": ["es7.decorators"],
  "plugins": ["babel-plugin-remove-decorator:before"]
}
 

Run tests

$ npm test

Package Sidebar

Install

npm i babel-plugin-remove-decorators

Weekly Downloads

2

Version

0.1.1

License

MIT

Last publish

Collaborators

  • vladpalos