* Desugar class properties to Object.defineProperty per spec * Define uninitialized static class properties with value=undefined * Make class-properties increased spec compliance opt-in (spec: true)
47 lines
709 B
Markdown
47 lines
709 B
Markdown
# babel-plugin-transform-class-properties
|
|
|
|
## Installation
|
|
|
|
```sh
|
|
$ 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**
|
|
|
|
```json
|
|
// without options
|
|
{
|
|
"plugins": ["transform-class-properties"]
|
|
}
|
|
|
|
// with options
|
|
{
|
|
"plugins": [
|
|
["transform-class-properties", { "spec": true }]
|
|
]
|
|
}
|
|
```
|
|
|
|
### Via CLI
|
|
|
|
```sh
|
|
$ babel --plugins transform-class-properties script.js
|
|
```
|
|
|
|
### Via Node API
|
|
|
|
```javascript
|
|
require("babel-core").transform("code", {
|
|
plugins: ["transform-class-properties"]
|
|
});
|
|
```
|