Similar to the fixes in https://github.com/babel/babel/pull/6580 and https://github.com/babel/babel/pull/6581, accesses of the form ```js nodesOut[nodesOut.length - 1] ``` where `nodesOut` can be an empty array, are bad for performance in Node. In this particular case it's easy to restructure the code a bit to not require the array access at all, but just track the current `tail` as we go. This is a non-breaking performance fix.
@babel/plugin-transform-es2015-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-es2015-destructuring
Usage
Via .babelrc (Recommended)
.babelrc
{
"plugins": ["@babel/transform-es2015-destructuring"]
}
Via CLI
babel --plugins @babel/transform-es2015-destructuring script.js
Via Node API
require("@babel/core").transform("code", {
plugins: ["@babel/transform-es2015-destructuring"]
});