Back parser state exportedIdentifiers by set (#13406)
This commit is contained in:
@@ -18,6 +18,9 @@ export default class BaseParser {
|
||||
declare expressionScope: ExpressionScopeHandler;
|
||||
declare plugins: PluginsMap;
|
||||
declare filename: ?string;
|
||||
// Names of exports store. `default` is stored as a name for both
|
||||
// `export default foo;` and `export { foo as default };`.
|
||||
declare exportedIdentifiers: Set<string>;
|
||||
sawUnambiguousESM: boolean = false;
|
||||
ambiguousScriptDifferentAst: boolean = false;
|
||||
|
||||
|
||||
@@ -2114,7 +2114,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
| N.ExportDefaultSpecifier,
|
||||
name: string,
|
||||
): void {
|
||||
if (this.state.exportedIdentifiers.indexOf(name) > -1) {
|
||||
if (this.exportedIdentifiers.has(name)) {
|
||||
this.raise(
|
||||
node.start,
|
||||
name === "default"
|
||||
@@ -2123,7 +2123,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
name,
|
||||
);
|
||||
}
|
||||
this.state.exportedIdentifiers.push(name);
|
||||
this.exportedIdentifiers.add(name);
|
||||
}
|
||||
|
||||
// Parses a comma-separated list of module exports.
|
||||
|
||||
@@ -349,8 +349,8 @@ export default class UtilParser extends Tokenizer {
|
||||
const oldLabels = this.state.labels;
|
||||
this.state.labels = [];
|
||||
|
||||
const oldExportedIdentifiers = this.state.exportedIdentifiers;
|
||||
this.state.exportedIdentifiers = [];
|
||||
const oldExportedIdentifiers = this.exportedIdentifiers;
|
||||
this.exportedIdentifiers = new Set();
|
||||
|
||||
// initialize scopes
|
||||
const oldInModule = this.inModule;
|
||||
@@ -372,7 +372,7 @@ export default class UtilParser extends Tokenizer {
|
||||
return () => {
|
||||
// Revert state
|
||||
this.state.labels = oldLabels;
|
||||
this.state.exportedIdentifiers = oldExportedIdentifiers;
|
||||
this.exportedIdentifiers = oldExportedIdentifiers;
|
||||
|
||||
// Revert scopes
|
||||
this.inModule = oldInModule;
|
||||
|
||||
@@ -148,10 +148,6 @@ export default class State {
|
||||
// after a non-directive is parsed
|
||||
strictErrors: Map<number, ErrorTemplate> = new Map();
|
||||
|
||||
// Names of exports store. `default` is stored as a name for both
|
||||
// `export default foo;` and `export { foo as default };`.
|
||||
exportedIdentifiers: Array<string> = [];
|
||||
|
||||
// Tokens length in token store
|
||||
tokensLength: number = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user