$ npm install babel-plugin-transform-class-properties
- Class properties are compiled to use
Object.defineProperty
- Static fields are now defined even if they are not initialized
.babelrc
// without options
{
"plugins": ["transform-class-properties"]
}
// with options
{
"plugins": [
["transform-class-properties", { "spec": true }]
]
}
$ babel --plugins transform-class-properties script.js
require("babel-core").transform("code", {
plugins: ["transform-class-properties"]
});