suppress hoist_props on export

fixes #2462
This commit is contained in:
alexlamsl 2017-11-10 11:48:12 +08:00
parent e6cfeb915e
commit db433f852f
2 changed files with 23 additions and 2 deletions

View File

@ -2895,7 +2895,8 @@ merge(Compressor.prototype, {
self.variables.each(function(def, name) { self.variables.each(function(def, name) {
var_names[name] = true; var_names[name] = true;
}); });
return self.transform(new TreeTransformer(function(node) { var tt = new TreeTransformer(function(node) {
if (node instanceof AST_Definitions && tt.parent() instanceof AST_Export) return node;
if (node instanceof AST_VarDef) { if (node instanceof AST_VarDef) {
var sym = node.name, def, value; var sym = node.name, def, value;
if (sym.scope === self if (sym.scope === self
@ -2946,7 +2947,8 @@ merge(Compressor.prototype, {
var_names[name] = true; var_names[name] = true;
return new_var; return new_var;
} }
})); });
return self.transform(tt);
}); });
// drop_side_effect_free() // drop_side_effect_free()

View File

@ -511,3 +511,22 @@ new_this: {
} }
expect_stdout: "1 2" expect_stdout: "1 2"
} }
issue_2462: {
options = {
hoist_props: true,
reduce_vars: true,
}
input: {
export const Foo = {
a: 1,
b: () => 2
};
}
expect: {
export const Foo = {
a: 1,
b: () => 2
};
}
}