Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): cache external reference resolution #21359

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/compiler/src/aot/static_reflector.ts
Expand Up @@ -47,6 +47,7 @@ export class StaticReflector implements CompileReflector {
private methodCache = new Map<StaticSymbol, {[key: string]: boolean}>();
private staticCache = new Map<StaticSymbol, string[]>();
private conversionMap = new Map<StaticSymbol, (context: StaticSymbol, args: any[]) => any>();
private resolvedExternalReferences = new Map<string, StaticSymbol>();
private injectionToken: StaticSymbol;
private opaqueToken: StaticSymbol;
ROUTES: StaticSymbol;
Expand Down Expand Up @@ -81,13 +82,22 @@ export class StaticReflector implements CompileReflector {
}

resolveExternalReference(ref: o.ExternalReference, containingFile?: string): StaticSymbol {
let key: string|undefined = undefined;
if (!containingFile) {
key = `${ref.moduleName}:${ref.name}`;
const declarationSymbol = this.resolvedExternalReferences.get(key);
if (declarationSymbol) return declarationSymbol;
}
const refSymbol =
this.symbolResolver.getSymbolByModule(ref.moduleName !, ref.name !, containingFile);
const declarationSymbol = this.findSymbolDeclaration(refSymbol);
if (!containingFile) {
this.symbolResolver.recordModuleNameForFileName(refSymbol.filePath, ref.moduleName !);
this.symbolResolver.recordImportAs(declarationSymbol, refSymbol);
}
if (key) {
this.resolvedExternalReferences.set(key, declarationSymbol);
}
return declarationSymbol;
}

Expand Down