fix(ngc): allow ReflectorHost passed as argument to CodeGenerator#create (#11951)
This commit is contained in:
parent
41c8c30973
commit
1564042fe8
|
@ -126,7 +126,7 @@ export class CodeGenerator {
|
||||||
static create(
|
static create(
|
||||||
options: AngularCompilerOptions, cliOptions: NgcCliOptions, program: ts.Program,
|
options: AngularCompilerOptions, cliOptions: NgcCliOptions, program: ts.Program,
|
||||||
compilerHost: ts.CompilerHost, reflectorHostContext?: ReflectorHostContext,
|
compilerHost: ts.CompilerHost, reflectorHostContext?: ReflectorHostContext,
|
||||||
resourceLoader?: compiler.ResourceLoader): CodeGenerator {
|
resourceLoader?: compiler.ResourceLoader, reflectorHost?: ReflectorHost): CodeGenerator {
|
||||||
resourceLoader = resourceLoader || {
|
resourceLoader = resourceLoader || {
|
||||||
get: (s: string) => {
|
get: (s: string) => {
|
||||||
if (!compilerHost.fileExists(s)) {
|
if (!compilerHost.fileExists(s)) {
|
||||||
|
@ -148,10 +148,12 @@ export class CodeGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
const urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver();
|
const urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver();
|
||||||
const usePathMapping = !!options.rootDirs && options.rootDirs.length > 0;
|
if (!reflectorHost) {
|
||||||
const reflectorHost = usePathMapping ?
|
const usePathMapping = !!options.rootDirs && options.rootDirs.length > 0;
|
||||||
new PathMappedReflectorHost(program, compilerHost, options, reflectorHostContext) :
|
reflectorHost = usePathMapping ?
|
||||||
new ReflectorHost(program, compilerHost, options, reflectorHostContext);
|
new PathMappedReflectorHost(program, compilerHost, options, reflectorHostContext) :
|
||||||
|
new ReflectorHost(program, compilerHost, options, reflectorHostContext);
|
||||||
|
}
|
||||||
const staticReflector = new StaticReflector(reflectorHost);
|
const staticReflector = new StaticReflector(reflectorHost);
|
||||||
StaticAndDynamicReflectionCapabilities.install(staticReflector);
|
StaticAndDynamicReflectionCapabilities.install(staticReflector);
|
||||||
const htmlParser =
|
const htmlParser =
|
||||||
|
|
Loading…
Reference in New Issue