fix(ivy): use CompilerHost.resolveModuleNames() if available (#30017)

Sometimes we need to override module resolution behaviour.
We do this by implementing the optional method `resolveModuleNames()`
on `CompilerHost`.

This commit ensures that we always try this method first before falling
back to the standard `ts.resolveModuleName`

PR Close #30017
This commit is contained in:
Pete Bacon Darwin
2019-05-01 14:03:39 +01:00
committed by Kara Erickson
parent 638ba4a2cf
commit 5b80ab372d
4 changed files with 27 additions and 10 deletions

View File

@ -33,7 +33,7 @@ import {IvyCompilation, declarationTransformFactory, ivyTransformFactory} from '
import {aliasTransformFactory} from './transform/src/alias';
import {TypeCheckContext, TypeCheckingConfig, typeCheckFilePath} from './typecheck';
import {normalizeSeparators} from './util/src/path';
import {getRootDirs, isDtsPath} from './util/src/typescript';
import {getRootDirs, isDtsPath, resolveModuleName} from './util/src/typescript';
export class NgtscProgram implements api.Program {
private tsProgram: ts.Program;
@ -253,10 +253,10 @@ export class NgtscProgram implements api.Program {
// of the root files.
const containingFile = this.tsProgram.getRootFileNames()[0];
const [entryPath, moduleName] = entryRoute.split('#');
const resolved = ts.resolveModuleName(entryPath, containingFile, this.options, this.host);
const resolvedModule = resolveModuleName(entryPath, containingFile, this.options, this.host);
if (resolved.resolvedModule) {
entryRoute = entryPointKeyFor(resolved.resolvedModule.resolvedFileName, moduleName);
if (resolvedModule) {
entryRoute = entryPointKeyFor(resolvedModule.resolvedFileName, moduleName);
}
}