refactor(ivy): move ngcc `rootDirs` computation into a function (#26082)
PR Close #26082
This commit is contained in:
parent
26209fca49
commit
64c96186da
|
@ -62,14 +62,7 @@ export class Transformer {
|
||||||
// Create the TS program and necessary helpers.
|
// Create the TS program and necessary helpers.
|
||||||
// TODO : create a custom compiler host that reads from .bak files if available.
|
// TODO : create a custom compiler host that reads from .bak files if available.
|
||||||
const host = ts.createCompilerHost(options);
|
const host = ts.createCompilerHost(options);
|
||||||
let rootDirs: string[]|undefined = undefined;
|
const rootDirs = this.getRootDirs(host, options);
|
||||||
if (options.rootDirs !== undefined) {
|
|
||||||
rootDirs = options.rootDirs;
|
|
||||||
} else if (options.rootDir !== undefined) {
|
|
||||||
rootDirs = [options.rootDir];
|
|
||||||
} else {
|
|
||||||
rootDirs = [host.getCurrentDirectory()];
|
|
||||||
}
|
|
||||||
const entryPointFilePath = entryPoint[format];
|
const entryPointFilePath = entryPoint[format];
|
||||||
if (!entryPointFilePath) {
|
if (!entryPointFilePath) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@ -113,6 +106,16 @@ export class Transformer {
|
||||||
writeMarkerFile(entryPoint, format);
|
writeMarkerFile(entryPoint, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRootDirs(host: ts.CompilerHost, options: ts.CompilerOptions) {
|
||||||
|
if (options.rootDirs !== undefined) {
|
||||||
|
return options.rootDirs;
|
||||||
|
} else if (options.rootDir !== undefined) {
|
||||||
|
return [options.rootDir];
|
||||||
|
} else {
|
||||||
|
return [host.getCurrentDirectory()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getHost(isCore: boolean, format: string, program: ts.Program, dtsMapper: DtsMapper):
|
getHost(isCore: boolean, format: string, program: ts.Program, dtsMapper: DtsMapper):
|
||||||
NgccReflectionHost {
|
NgccReflectionHost {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
|
|
Loading…
Reference in New Issue