babel/packages/babel-plugin-syntax-decorators
Nicolò Ribaudo cb17f07ac9
Update syntax-decorators options (#7938)
* Add decoratorsBeforeExport to the syntax plugin
* Require legacy: true, like in the transform plugin
2018-05-30 22:00:18 +02:00
..
2017-03-25 21:46:16 -04:00
2018-05-25 09:00:02 -07:00

@babel/plugin-syntax-decorators

Allow parsing of decorators.

Installation

npm install --save-dev @babel/plugin-syntax-decorators

Usage

.babelrc

{
  "plugins": ["@babel/plugin-syntax-decorators"]
}

Via CLI

babel --plugins @babel/plugin-syntax-decorators script.js

Via Node API

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

Options

legacy

boolean, defaults to false.

Use the legacy (stage 1) decorators syntax.

decoratorsBeforeExport

boolean, defaults to true.

// decoratorsBeforeExport: true
@decorator
export class Foo {}

// decoratorsBeforeExport: false
export @decorator class Bar {}

This option was added to help tc39 collect feedback from the community by allowing experimentation with both possible syntaxes.

For more information, check out: tc39/proposal-decorators#69