$ npm install babel-plugin-transform-es5-property-mutators
This plugin allows Babel to transform object initializer mutators into
Object.defineProperties
.
In
var foo = {
get bar() {
return "bar";
}
};
Out
var foo = Object.defineProperties({}, {
bar: {
get: function () {
return "bar";
},
enumerable: true,
configurable: true
}
});
npm install --save-dev babel-plugin-transform-es5-property-mutators
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-es5-property-mutators"]
}
babel --plugins transform-es5-property-mutators script.js
require("babel-core").transform("code", {
plugins: ["transform-es5-property-mutators"]
});
© 2010 - cnpmjs.org x YWFE | Home | YWFE