$ npm install babel-plugin-transform-property-literals
This plugin allows Babel to transform valid identifier property key literals into identifiers.
In
var foo = {
// changed
"bar": function () {},
"1": function () {},
// not changed
"default": 1,
[a]: 2,
foo: 1
};
Out
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"]
});
© 2010 - cnpmjs.org x YWFE | Home | YWFE