From 1564042fe858b714d42642725c8de1185f920fa9 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Tue, 27 Sep 2016 17:12:57 -0700 Subject: [PATCH] fix(ngc): allow ReflectorHost passed as argument to CodeGenerator#create (#11951) --- modules/@angular/compiler-cli/src/codegen.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/@angular/compiler-cli/src/codegen.ts b/modules/@angular/compiler-cli/src/codegen.ts index 91048668a0..354ee466c1 100644 --- a/modules/@angular/compiler-cli/src/codegen.ts +++ b/modules/@angular/compiler-cli/src/codegen.ts @@ -126,7 +126,7 @@ export class CodeGenerator { static create( options: AngularCompilerOptions, cliOptions: NgcCliOptions, program: ts.Program, compilerHost: ts.CompilerHost, reflectorHostContext?: ReflectorHostContext, - resourceLoader?: compiler.ResourceLoader): CodeGenerator { + resourceLoader?: compiler.ResourceLoader, reflectorHost?: ReflectorHost): CodeGenerator { resourceLoader = resourceLoader || { get: (s: string) => { if (!compilerHost.fileExists(s)) { @@ -148,10 +148,12 @@ export class CodeGenerator { } const urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver(); - const usePathMapping = !!options.rootDirs && options.rootDirs.length > 0; - const reflectorHost = usePathMapping ? - new PathMappedReflectorHost(program, compilerHost, options, reflectorHostContext) : - new ReflectorHost(program, compilerHost, options, reflectorHostContext); + if (!reflectorHost) { + const usePathMapping = !!options.rootDirs && options.rootDirs.length > 0; + reflectorHost = usePathMapping ? + new PathMappedReflectorHost(program, compilerHost, options, reflectorHostContext) : + new ReflectorHost(program, compilerHost, options, reflectorHostContext); + } const staticReflector = new StaticReflector(reflectorHost); StaticAndDynamicReflectionCapabilities.install(staticReflector); const htmlParser =