BundlerMinifier
BundlerMinifier copied to clipboard
Erroneous minification when using arrow function parameter list
Installed product versions
- Visual Studio: 2019 Enterprise
- This extension: 2.8.396 VS Extension
Description
When a js file contains an arrow function parameter list, the minified result is malformed.
Steps to recreate
- Create a JS file with this content:
var test = [[1, 2], [2, 3], [3, 4]];
var testFilter = [];
test.filter(([index1, index2]) => testFilter.push(index1 + index2));
console.log(testFilter);
- Minify it.
- Run the minified result and you will get a malformed error.
Current behavior
It will currently minify the above code to:
var test=[[1,2],[2,3],[3,4]],testFilter=[];test.filter([n,t]=>testFilter.push(n+t));console.log(testFilter);
Which is missing brakets around [n,t]
.
Expected behavior
The result should be runnable JS, or in this case, its missing brackets, the corrected version is:
var test=[[1,2],[2,3],[3,4]],testFilter=[];test.filter(([n,t])=>testFilter.push(n+t));console.log(testFilter);
Yes, it's a bug.
Paste the code here and see a good result: https://skalman.github.io/UglifyJS-online
I have the same problem.
Do not minify with the arrow syntax or features of ES8.
I find the nuget package very useful but I would have to minify the more modern JS.
Thanks!!