fix mangle on export (#2133)

- `export default ...`
- `export` with `AST_Destructuring`

fixes #2129
This commit is contained in:
Alex Lam S.L
2017-06-21 14:22:09 +08:00
committed by GitHub
parent db877e8729
commit 8709753bfb
3 changed files with 21 additions and 3 deletions

View File

@@ -234,8 +234,14 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
}
function mark_export(def, level) {
if (in_destructuring) {
var i = 0;
do {
level++;
} while (tw.parent(i++) !== in_destructuring);
}
var node = tw.parent(level);
def.export = node instanceof AST_Export && !node.is_default;
def.export = node instanceof AST_Export;
}
});
self.walk(tw);

View File

@@ -95,3 +95,15 @@ issue_2131: {
};
}
}
issue_2129: {
mangle = {
toplevel: true,
}
input: {
export const { keys } = Object;
}
expect: {
export const { keys } = Object;
}
}

View File

@@ -171,7 +171,7 @@ export_mangle_2: {
return one - two;
};
}
expect_exact: "export default function n(n,r){return n-r};"
expect_exact: "export default function foo(n,o){return n-o};"
}
export_mangle_3: {
@@ -207,7 +207,7 @@ export_mangle_4: {
}
};
}
expect_exact: "export default class n{go(n,r){return n-r+n}};"
expect_exact: "export default class C{go(n,r){return n-r+n}};"
}
export_mangle_5: {