From 43c0e9a6bb83bef9f8169158023edc59f2689259 Mon Sep 17 00:00:00 2001 From: Chuck Jazdzewski Date: Wed, 30 Nov 2016 11:07:02 -0800 Subject: [PATCH] fix(compiler): fix performance regression caused by 5b0f9e2 Fixes #13146 --- modules/@angular/compiler/src/metadata_resolver.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/@angular/compiler/src/metadata_resolver.ts b/modules/@angular/compiler/src/metadata_resolver.ts index 7bda86c672..faba178acb 100644 --- a/modules/@angular/compiler/src/metadata_resolver.ts +++ b/modules/@angular/compiler/src/metadata_resolver.ts @@ -126,7 +126,7 @@ export class CompileMetadataResolver { return null; } - private _loadDirectiveMetadata(directiveType: any, isSync: boolean): Promise { + private _loadDirectiveMetadata(directiveType: any, isSync: boolean): () => Promise { if (this._directiveCache.has(directiveType)) { return; } @@ -176,7 +176,7 @@ export class CompileMetadataResolver { if (isSync) { throw new ComponentStillLoadingError(directiveType); } - return templateMeta.asyncResult.then(createDirectiveMetadata); + return () => templateMeta.asyncResult.then(createDirectiveMetadata); } } else { // directive @@ -423,8 +423,10 @@ export class CompileMetadataResolver { transitiveModule.directives.push(declaredIdentifier); declaredDirectives.push(declaredIdentifier); this._addTypeToModule(declaredType, moduleType); - transitiveModule.directiveLoaders.push( - () => this._loadDirectiveMetadata(declaredType, isSync)); + const loader = this._loadDirectiveMetadata(declaredType, isSync); + if (loader) { + transitiveModule.directiveLoaders.push(loader); + } } else if (this._pipeResolver.isPipe(declaredType)) { transitiveModule.pipesSet.add(declaredType); transitiveModule.pipes.push(declaredIdentifier);