diff options
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 5f8f3736..0a46fb26 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -8018,7 +8018,7 @@ merge(Compressor.prototype, { } } var fn = exp instanceof AST_SymbolRef ? exp.fixed_value() : exp; - var is_func = fn instanceof AST_Arrow || fn instanceof AST_Defun || fn instanceof AST_Function; + var is_func = fn instanceof AST_Lambda && (!is_async(fn) || compressor.parent() instanceof AST_Await); var stat = is_func && fn.first_statement(); var has_default = false; var can_drop = is_func && all(fn.argnames, function(argname, index) { @@ -8649,6 +8649,19 @@ merge(Compressor.prototype, { ? self : try_evaluate(compressor, self); }); + OPT(AST_Await, function(self, compressor) { + if (compressor.option("sequences")) { + var seq = lift_sequence_in_expression(self, compressor); + if (seq !== self) return seq.optimize(compressor); + } + if (compressor.option("side_effects")) { + var exp = self.expression; + if (exp instanceof AST_Await) return exp; + if (exp instanceof AST_UnaryPrefix && exp.expression instanceof AST_Await) return exp; + } + return self; + }); + AST_Binary.DEFMETHOD("lift_sequences", function(compressor) { if (this.left instanceof AST_PropAccess) { if (!(this.left.expression instanceof AST_Sequence)) return this; |