minify icon indicating copy to clipboard operation
minify copied to clipboard

Remove parentheses around anonymous functions

Open bbrk24 opened this issue 4 years ago • 4 comments
trafficstars

It seems that currently, this adds parentheses around every arrow function, such as giving:

arr.reduce(((e,t)=>e+t),0)

which could be:

arr.reduce((e,t)=>e+t,0)

bbrk24 avatar Oct 10 '21 15:10 bbrk24

Looks like default options are missing https://github.com/terser/terser, do you have any ideas what should be added?

coderaiser avatar Oct 17 '21 06:10 coderaiser

Hm, I'm not really sure. Providing all of them is a bit much -- at some point, you just use terser directly. To address the issue, you should at least provide the format options wrap_iife and wrap_func_args, and probably also the compress option negate_iife.

bbrk24 avatar Oct 19 '21 22:10 bbrk24

Sounds reasonable, are you willing for a PR?

coderaiser avatar Oct 20 '21 10:10 coderaiser

Sure, if I get the chance I would like to, but I'm not sure whether I'd be able to in a reasonable amount of time.

bbrk24 avatar Oct 20 '21 20:10 bbrk24

Looks like this is no longer an issue, since Minify v10:

$ echo 'arr.reduce(((e,t)=>e+t),0)'| bin/minify.js --js
arr.reduce((e, t)=>e+t,0);

coderaiser avatar May 24 '23 15:05 coderaiser