输入
var foo = {
// changed
"bar": function () {},
"1": function () {},
// not changed
"default": 1,
[a]: 2,
foo: 1
};
输出
var foo = {
bar: function () {},
1: function () {},
"default": 1,
[a]: 2,
foo: 1
};
npm install babel-plugin-transform-property-literals
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-property-literals"]
}
babel --plugins transform-property-literals script.js
require("babel-core").transform("code", {
plugins: ["transform-property-literals"]
});