Introduce new compress option unsafe_arrows (#2278)

* Not always safe to convert a function expression to an arrow
  function when code depends on the function prototype existing.

Fixes #2271
This commit is contained in:
kzc
2017-08-16 10:51:26 -04:00
committed by Alex Lam S.L
parent a5461e0adc
commit ae0f117da6
4 changed files with 52 additions and 10 deletions

View File

@@ -84,6 +84,7 @@ function Compressor(options, false_by_default) {
toplevel : !!(options && options["top_retain"]),
typeofs : !false_by_default,
unsafe : false,
unsafe_arrows : false,
unsafe_comps : false,
unsafe_Func : false,
unsafe_math : false,
@@ -4748,7 +4749,7 @@ merge(Compressor.prototype, {
OPT(AST_Function, function(self, compressor){
tighten_body(self.body, compressor);
if (compressor.option("arrows")
if (compressor.option("unsafe_arrows")
&& compressor.option("ecma") >= 6
&& !self.name
&& !self.is_generator