esmangle icon indicating copy to clipboard operation
esmangle copied to clipboard

Add option to use ES.next syntax features for even smaller minified output

Open mathiasbynens opened this issue 10 years ago • 1 comments

The option could be something like:

format: {
    es6: true
}

…or es2015 or a more generic esnext.


A simple example of what it would do:

var foo = function(a) {
  return a * 2;
};

…currently minifies to:

var foo=function(a){return a*2}

With ES.next syntax it could be:

var foo=a=>a*2

(Only watch out for function bodies that make use of the this binding.)

There’s far more things that could be done, e.g. string literals containing new line characters or lots of quotes could sometimes be shortened by using template strings, etc.

mathiasbynens avatar Feb 05 '15 10:02 mathiasbynens

Nice. Now, escodegen already supports ES6. So, to support it, we need to do,

  1. Update the parser
  2. Update the rules to support ES6 semantics

Maybe 1 is easy. We need to do 2. After updating escope to support, we can work on (2) :)

Constellation avatar Feb 07 '15 21:02 Constellation