refactor(ngcc): resolve modules based on the provided moduleResolver (#34494)

The `DependencyHost` implementations were duplicating the "postfix" strings
which are used to find matching paths when resolving module specifiers.
Now the hosts reuse the postfixes given to the `ModuleResolver` that is
passed to the host.

PR Close #34494
This commit is contained in:
Pete Bacon Darwin
2019-12-19 22:43:12 +00:00
committed by Alex Rickabaugh
parent e2b184515b
commit 69950e3888
3 changed files with 36 additions and 2 deletions

View File

@ -39,7 +39,7 @@ export abstract class DependencyHostBase implements DependencyHost {
collectDependencies(
entryPointPath: AbsoluteFsPath, {dependencies, missing, deepImports}: DependencyInfo): void {
const resolvedFile =
resolveFileWithPostfixes(this.fs, entryPointPath, ['', '.js', '/index.js']);
resolveFileWithPostfixes(this.fs, entryPointPath, this.moduleResolver.relativeExtensions);
if (resolvedFile !== null) {
const alreadySeen = new Set<AbsoluteFsPath>();
this.recursivelyCollectDependencies(

View File

@ -24,7 +24,7 @@ import {PathMappings, isRelativePath, resolveFileWithPostfixes} from '../utils';
export class ModuleResolver {
private pathMappings: ProcessedPathMapping[];
constructor(private fs: FileSystem, pathMappings?: PathMappings, private relativeExtensions = [
constructor(private fs: FileSystem, pathMappings?: PathMappings, readonly relativeExtensions = [
'', '.js', '/index.js'
]) {
this.pathMappings = pathMappings ? this.processPathMappings(pathMappings) : [];