diff --git a/packages/compiler/src/aot/static_reflector.ts b/packages/compiler/src/aot/static_reflector.ts index 13a57bedf9..c8349e517d 100644 --- a/packages/compiler/src/aot/static_reflector.ts +++ b/packages/compiler/src/aot/static_reflector.ts @@ -47,6 +47,7 @@ export class StaticReflector implements CompileReflector { private methodCache = new Map(); private staticCache = new Map(); private conversionMap = new Map any>(); + private resolvedExternalReferences = new Map(); private injectionToken: StaticSymbol; private opaqueToken: StaticSymbol; ROUTES: StaticSymbol; @@ -81,6 +82,12 @@ 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); @@ -88,6 +95,9 @@ export class StaticReflector implements CompileReflector { this.symbolResolver.recordModuleNameForFileName(refSymbol.filePath, ref.moduleName !); this.symbolResolver.recordImportAs(declarationSymbol, refSymbol); } + if (key) { + this.resolvedExternalReferences.set(key, declarationSymbol); + } return declarationSymbol; }