BundlerMinifier icon indicating copy to clipboard operation
BundlerMinifier copied to clipboard

Erroneous minification when using arrow function parameter list

Open Darkov3 opened this issue 4 years ago • 2 comments

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

  1. 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);
  1. Minify it.
  2. 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);

Darkov3 avatar Mar 26 '20 18:03 Darkov3

Yes, it's a bug.

Paste the code here and see a good result: https://skalman.github.io/UglifyJS-online

Dean-NC avatar Apr 03 '20 19:04 Dean-NC

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!!

sanmolhec avatar Apr 30 '20 11:04 sanmolhec