@@ -3425,6 +3425,7 @@ merge(Compressor.prototype, {
|
||||
if (parent instanceof AST_For && parent.init === node) return null;
|
||||
return in_list ? List.skip : make_node(AST_EmptyStatement, node);
|
||||
}
|
||||
if (node instanceof AST_ExportDeclaration) return node;
|
||||
if (node instanceof AST_Scope) return node;
|
||||
if (!is_statement(node)) return node;
|
||||
}));
|
||||
@@ -6167,7 +6168,9 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
var old_def;
|
||||
if (!value && !(node instanceof AST_Let)) {
|
||||
if (drop_sym && var_defs[sym.id] > 1) {
|
||||
if (parent instanceof AST_ExportDeclaration) {
|
||||
flush();
|
||||
} else if (drop_sym && var_defs[sym.id] > 1) {
|
||||
AST_Node.info("Dropping declaration of variable {name} [{file}:{line},{col}]", template(def.name));
|
||||
var_defs[sym.id]--;
|
||||
sym.eliminated++;
|
||||
|
||||
11
lib/scope.js
11
lib/scope.js
@@ -198,9 +198,10 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
||||
} else if (node instanceof AST_SymbolConst) {
|
||||
var def = scope.def_variable(node);
|
||||
def.defun = defun;
|
||||
def.exported = exported;
|
||||
if (exported) def.exported = true;
|
||||
} else if (node instanceof AST_SymbolDefun) {
|
||||
defun.def_function(node, tw.parent()).exported = exported;
|
||||
var def = defun.def_function(node, tw.parent());
|
||||
if (exported) def.exported = true;
|
||||
entangle(defun, scope);
|
||||
} else if (node instanceof AST_SymbolFunarg) {
|
||||
defun.def_variable(node);
|
||||
@@ -209,9 +210,11 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
||||
var def = defun.def_function(node, node.name == "arguments" ? undefined : defun);
|
||||
if (options.ie8) def.defun = defun.parent_scope.resolve();
|
||||
} else if (node instanceof AST_SymbolLet) {
|
||||
scope.def_variable(node).exported = exported;
|
||||
var def = scope.def_variable(node);
|
||||
if (exported) def.exported = true;
|
||||
} else if (node instanceof AST_SymbolVar) {
|
||||
defun.def_variable(node, node instanceof AST_SymbolImport ? undefined : null).exported = exported;
|
||||
var def = defun.def_variable(node, node instanceof AST_SymbolImport ? undefined : null);
|
||||
if (exported) def.exported = true;
|
||||
entangle(defun, scope);
|
||||
}
|
||||
|
||||
|
||||
@@ -382,3 +382,62 @@ single_use_class_default: {
|
||||
A.prototype.p = "PASS";
|
||||
}
|
||||
}
|
||||
|
||||
issue_4742_join_vars_1: {
|
||||
options = {
|
||||
join_vars: true,
|
||||
}
|
||||
input: {
|
||||
var a = 42;
|
||||
export var a;
|
||||
}
|
||||
expect: {
|
||||
var a = 42;
|
||||
export var a;
|
||||
}
|
||||
}
|
||||
|
||||
issue_4742_join_vars_2: {
|
||||
options = {
|
||||
join_vars: true,
|
||||
}
|
||||
input: {
|
||||
export var a = "foo";
|
||||
var b;
|
||||
b = "bar";
|
||||
}
|
||||
expect: {
|
||||
export var a = "foo";
|
||||
var b, b = "bar";
|
||||
}
|
||||
}
|
||||
|
||||
issue_4742_unused_1: {
|
||||
options = {
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = 42;
|
||||
export var a;
|
||||
}
|
||||
expect: {
|
||||
var a = 42;
|
||||
export var a;
|
||||
}
|
||||
}
|
||||
|
||||
issue_4742_unused_2: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
export var a = "foo";
|
||||
var a = "bar";
|
||||
}
|
||||
expect: {
|
||||
export var a = "foo";
|
||||
a = "bar";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user