Properly parse export default from when exportDefaultFrom is not enabled (#11676)

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
Huáng Jùnliàng
2020-06-05 10:08:21 -04:00
committed by GitHub
parent 3874470841
commit 71d3527ef5
22 changed files with 279 additions and 6 deletions

View File

@@ -251,6 +251,23 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return super.parseExport(node);
}
isExportDefaultSpecifier(): boolean {
if (this.match(tt._default)) {
const next = this.nextTokenStart();
if (this.isUnparsedContextual(next, "from")) {
if (
this.input.startsWith(
tt.placeholder.label,
this.nextTokenStartSince(next + 4),
)
) {
return true;
}
}
}
return super.isExportDefaultSpecifier();
}
maybeParseExportDefaultSpecifier(node: N.Node): boolean {
if (node.specifiers && node.specifiers.length > 0) {
// "export %%NAME%%" has already been parsed by #parseExport.