fix corner cases with export (#4699)

fixes #4698
fixes #4700
fixes #4701
fixes #4702
This commit is contained in:
Alex Lam S.L
2021-02-27 02:15:14 +00:00
committed by GitHub
parent 0a42457df6
commit e6ebf827ce
4 changed files with 32 additions and 8 deletions

View File

@@ -238,7 +238,7 @@ function HOP(obj, prop) {
// return true if the node at the top of the stack (that means the
// innermost node in the current output) is lexically the first in
// a statement.
function first_in_statement(stack, arrow) {
function first_in_statement(stack, arrow, export_default) {
var node = stack.parent(-1);
for (var i = 0, p; p = stack.parent(i++); node = p) {
if (is_arrow(p)) {
@@ -250,7 +250,7 @@ function first_in_statement(stack, arrow) {
} else if (p instanceof AST_Conditional) {
if (p.condition === node) continue;
} else if (p instanceof AST_ExportDefault) {
return false;
return export_default;
} else if (p instanceof AST_PropAccess) {
if (p.expression === node) continue;
} else if (p instanceof AST_Sequence) {