* No unneeded empty arrays in transform spread Since Array.prototype.concat creates a new array from inputs, there's no need to call it from a new empty array ([].concat()). * [fixup] simplify detection of new array
@babel/plugin-transform-destructuring
Compile ES2015 destructuring to ES5
Examples
In
let arr = [1,2,3];
let {x, y, z} = arr;
Out
var arr = [1, 2, 3];
var x = arr.x,
y = arr.y,
z = arr.z;
Installation
npm install --save-dev @babel/plugin-transform-destructuring
Usage
Via .babelrc (Recommended)
.babelrc
{
"plugins": ["@babel/transform-destructuring"]
}
Via CLI
babel --plugins @babel/transform-destructuring script.js
Via Node API
require("@babel/core").transform("code", {
plugins: ["@babel/transform-destructuring"]
});