support arbitary export specifiers

This commit is contained in:
erik-krogh
2024-08-06 20:36:55 +02:00
parent 5f7f37f6c8
commit b8187ed294
3 changed files with 23 additions and 1 deletions

View File

@@ -3547,7 +3547,19 @@ public class Parser {
SourceLocation loc = new SourceLocation(this.startLoc);
Identifier local = this.parseIdent(this.type == TokenType._default);
Identifier exported = this.eatContextual("as") ? this.parseIdent(true) : local;
Identifier exported;
if (!this.eatContextual("as")) {
exported = local;
} else {
if (this.type == TokenType.string) {
// e.g. `export { Foo_new as "Foo::new" }`
Expression string = this.parseExprAtom(null);
String str = ((Literal)string).getStringValue();
exported = new Identifier(loc, str);
} else {
exported = this.parseIdent(true);
}
}
checkExport(exports, exported.getName(), exported.getLoc().getStart());
nodes.add(this.finishNode(new ExportSpecifier(loc, local, exported)));
}