node package manager

babel-plugin-transform-class-properties

This plugin transforms static class properties as well as properties declared with the property initializer syntax

babel-plugin-transform-class-properties

Installation

$ npm install babel-plugin-transform-class-properties

Options: spec

  • Class properties are compiled to use Object.defineProperty
  • Static fields are now defined even if they are not initialized

Usage

Via .babelrc (Recommended)

.babelrc

// without options
{
  "plugins": ["transform-class-properties"]
}
 
// with options
{
  "plugins": [
    ["transform-class-properties", { "spec": true }]
  ]
}

Via CLI

$ babel --plugins transform-class-properties script.js

Via Node API

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