fix hoist_funs on export

This commit is contained in:
alexlamsl 2017-05-26 05:07:28 +08:00
parent 269df9267c
commit e5d93f1555
2 changed files with 7 additions and 1 deletions

View File

@ -2384,7 +2384,7 @@ merge(Compressor.prototype, {
dirs.push(node);
return make_node(AST_EmptyStatement, node);
}
if (node instanceof AST_Defun && hoist_funs) {
if (hoist_funs && node instanceof AST_Defun && !(tt.parent() instanceof AST_Export)) {
hoisted.push(node);
return make_node(AST_EmptyStatement, node);
}

View File

@ -1,5 +1,6 @@
export_func_1: {
options = {
hoist_funs: true,
unused: true,
}
input: {
@ -10,6 +11,7 @@ export_func_1: {
export_func_2: {
options = {
hoist_funs: true,
side_effects: false,
unused: true,
}
@ -21,6 +23,7 @@ export_func_2: {
export_func_3: {
options = {
hoist_funs: true,
side_effects: true,
unused: true,
}
@ -32,6 +35,7 @@ export_func_3: {
export_default_func_1: {
options = {
hoist_funs: true,
unused: true,
}
input: {
@ -42,6 +46,7 @@ export_default_func_1: {
export_default_func_2: {
options = {
hoist_funs: true,
side_effects: false,
unused: true,
}
@ -53,6 +58,7 @@ export_default_func_2: {
export_default_func_3: {
options = {
hoist_funs: true,
side_effects: true,
unused: true,
}