Skip to content
Permalink
Browse files

fix(ngcc): handle deep imports that already have an extension (#32181)

During the dependency analysis phase of ngcc, imports are resolved to
files on disk according to certain module resolution rules. Since module
specifiers are typically missing extensions, or can refer to index.js
barrel files within a directory, the module resolver attempts several
postfixes when searching for a module import on disk. Module  specifiers
that already include an extension, however, would fail to be resolved as
ngcc's module resolver failed to check the location on disk without
adding any postfixes.

Closes #32097

PR Close #32181
  • Loading branch information...
JoostK authored and AndrewKushnir committed Aug 18, 2019
1 parent ae142a6 commit 4bbf16e654351a9b4f1fcb5e68c91f2d29f66682
@@ -25,7 +25,7 @@ export class ModuleResolver {
private pathMappings: ProcessedPathMapping[];

constructor(private fs: FileSystem, pathMappings?: PathMappings, private relativeExtensions = [
'.js', '/index.js'
'', '.js', '/index.js'
]) {
this.pathMappings = pathMappings ? this.processPathMappings(pathMappings) : [];
}
@@ -83,6 +83,12 @@ runInEachFileSystem(() => {
const resolver = new ModuleResolver(getFileSystem());
expect(resolver.resolveModuleImport('./y', _('/libs/local-package/index.js'))).toBe(null);
});

it('should resolve modules that already include an extension', () => {
const resolver = new ModuleResolver(getFileSystem());
expect(resolver.resolveModuleImport('./x.js', _('/libs/local-package/index.js')))
.toEqual(new ResolvedRelativeModule(_('/libs/local-package/x.js')));
});
});

describe('with non-mapped external paths', () => {

0 comments on commit 4bbf16e

Please sign in to comment.
You can’t perform that action at this time.