babel-plugin-transform-es5-property-mutators

Compile ES5 property mutator shorthand syntax to Object.defineProperty

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
babel-plugin-transform-es5-property-mutators
6.24.16 years ago7 years agoMinified + gzip package size for babel-plugin-transform-es5-property-mutators in KB

Readme

babel-plugin-transform-es5-property-mutators
This plugin allows Babel to transform object initializer mutators into Object.defineProperties.

Example

In
var foo = {
  get bar() {
    return "bar";
  }
};

Out
var foo = Object.defineProperties({}, {
  bar: {
    get: function () {
      return "bar";
    },
    enumerable: true,
    configurable: true
  }
});

Installation

npm install --save-dev babel-plugin-transform-es5-property-mutators

Usage

Via .babelrc (Recommended)

.babelrc
{
  "plugins": ["transform-es5-property-mutators"]
}

Via CLI

babel --plugins transform-es5-property-mutators script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-es5-property-mutators"]
});