@@ -189,6 +189,10 @@ Compressor.prototype = new TreeTransformer(function(node, descend, in_list) {
|
|||||||
if (node._squeezed) return node;
|
if (node._squeezed) return node;
|
||||||
var is_scope = node instanceof AST_Scope;
|
var is_scope = node instanceof AST_Scope;
|
||||||
if (is_scope) {
|
if (is_scope) {
|
||||||
|
if (this.option("arrows") && is_arrow(node) && node.value) {
|
||||||
|
node.body = [ node.first_statement() ];
|
||||||
|
node.value = null;
|
||||||
|
}
|
||||||
node.hoist_properties(this);
|
node.hoist_properties(this);
|
||||||
node.hoist_declarations(this);
|
node.hoist_declarations(this);
|
||||||
node.process_returns(this);
|
node.process_returns(this);
|
||||||
@@ -8449,6 +8453,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
|
AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
|
||||||
if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return;
|
if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
if (is_arrow(self) && self.value) return;
|
||||||
var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
|
var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
|
||||||
var defs_by_id = Object.create(null);
|
var defs_by_id = Object.create(null);
|
||||||
var tt = new TreeTransformer(function(node, descend) {
|
var tt = new TreeTransformer(function(node, descend) {
|
||||||
@@ -8486,18 +8491,9 @@ Compressor.prototype.compress = function(node) {
|
|||||||
return make_sequence(node, assignments);
|
return make_sequence(node, assignments);
|
||||||
}
|
}
|
||||||
if (node instanceof AST_Scope) {
|
if (node instanceof AST_Scope) {
|
||||||
var parent;
|
if (node === self) return;
|
||||||
if (node === self || (parent = tt.parent()).TYPE == "Call" && parent.expression === node) {
|
var parent = tt.parent();
|
||||||
if (!(is_arrow(node) && node.value)) return;
|
if (parent.TYPE == "Call" && parent.expression === node) return;
|
||||||
var stat = node.first_statement();
|
|
||||||
node.body = [ stat ];
|
|
||||||
node.value = null;
|
|
||||||
descend(node, tt);
|
|
||||||
if (node.body.length == 1 && node.body[0] === stat) {
|
|
||||||
node.body.length = 0;
|
|
||||||
node.value = stat.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_VarDef) {
|
if (node instanceof AST_VarDef) {
|
||||||
|
|||||||
@@ -668,6 +668,28 @@ single_use_recursive: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline_iife_within_arrow: {
|
||||||
|
options = {
|
||||||
|
arrows: true,
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var f = () => console.log(function(a) {
|
||||||
|
return Math.ceil(a);
|
||||||
|
}(Math.random()));
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var f = () => {
|
||||||
|
return console.log((a = Math.random(), Math.ceil(a)));
|
||||||
|
var a;
|
||||||
|
};
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect_stdout: "1"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
issue_4388: {
|
issue_4388: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user