fix(compiler): fix performance regression caused by 5b0f9e2

Fixes #13146
This commit is contained in:
Chuck Jazdzewski 2016-11-30 11:07:02 -08:00 committed by Alex Rickabaugh
parent f275f36081
commit 43c0e9a6bb
1 changed files with 6 additions and 4 deletions

View File

@ -126,7 +126,7 @@ export class CompileMetadataResolver {
return null; return null;
} }
private _loadDirectiveMetadata(directiveType: any, isSync: boolean): Promise<any> { private _loadDirectiveMetadata(directiveType: any, isSync: boolean): () => Promise<any> {
if (this._directiveCache.has(directiveType)) { if (this._directiveCache.has(directiveType)) {
return; return;
} }
@ -176,7 +176,7 @@ export class CompileMetadataResolver {
if (isSync) { if (isSync) {
throw new ComponentStillLoadingError(directiveType); throw new ComponentStillLoadingError(directiveType);
} }
return templateMeta.asyncResult.then(createDirectiveMetadata); return () => templateMeta.asyncResult.then(createDirectiveMetadata);
} }
} else { } else {
// directive // directive
@ -423,8 +423,10 @@ export class CompileMetadataResolver {
transitiveModule.directives.push(declaredIdentifier); transitiveModule.directives.push(declaredIdentifier);
declaredDirectives.push(declaredIdentifier); declaredDirectives.push(declaredIdentifier);
this._addTypeToModule(declaredType, moduleType); this._addTypeToModule(declaredType, moduleType);
transitiveModule.directiveLoaders.push( const loader = this._loadDirectiveMetadata(declaredType, isSync);
() => this._loadDirectiveMetadata(declaredType, isSync)); if (loader) {
transitiveModule.directiveLoaders.push(loader);
}
} else if (this._pipeResolver.isPipe(declaredType)) { } else if (this._pipeResolver.isPipe(declaredType)) {
transitiveModule.pipesSet.add(declaredType); transitiveModule.pipesSet.add(declaredType);
transitiveModule.pipes.push(declaredIdentifier); transitiveModule.pipes.push(declaredIdentifier);