Transform object initializer mutators into Object.defineProperties
GitHub · npm · Edit this page
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"]
});