fix mangle on export (#2133)
- `export default ...` - `export` with `AST_Destructuring` fixes #2129
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -95,3 +95,15 @@ issue_2131: {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
issue_2129: {
|
||||
mangle = {
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
export const { keys } = Object;
|
||||
}
|
||||
expect: {
|
||||
export const { keys } = Object;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user