diff --git a/packages/compiler-cli/ngcc/src/dependencies/dependency_resolver.ts b/packages/compiler-cli/ngcc/src/dependencies/dependency_resolver.ts index 02d4a26013..316dc2c474 100644 --- a/packages/compiler-cli/ngcc/src/dependencies/dependency_resolver.ts +++ b/packages/compiler-cli/ngcc/src/dependencies/dependency_resolver.ts @@ -81,7 +81,7 @@ export class DependencyResolver { let sortedEntryPointNodes: string[]; if (target) { - if (target.compiledByAngular) { + if (target.compiledByAngular && graph.hasNode(target.path)) { sortedEntryPointNodes = graph.dependenciesOf(target.path); sortedEntryPointNodes.push(target.path); } else { diff --git a/packages/compiler-cli/ngcc/test/dependencies/dependency_resolver_spec.ts b/packages/compiler-cli/ngcc/test/dependencies/dependency_resolver_spec.ts index abb47d0fef..6d395632d7 100644 --- a/packages/compiler-cli/ngcc/test/dependencies/dependency_resolver_spec.ts +++ b/packages/compiler-cli/ngcc/test/dependencies/dependency_resolver_spec.ts @@ -179,6 +179,19 @@ runInEachFileSystem(() => { expect(sorted.entryPoints).toEqual([fifth]); }); + it('should not process the provided target if it has missing dependencies', () => { + spyOn(host, 'findDependencies').and.callFake(createFakeComputeDependencies({ + [_('/first/index.js')]: {resolved: [], missing: ['/missing']}, + })); + const entryPoints = [first]; + let sorted: SortedEntryPointsInfo; + + sorted = resolver.sortEntryPointsByDependency(entryPoints, first); + expect(sorted.entryPoints).toEqual([]); + expect(sorted.invalidEntryPoints[0].entryPoint).toEqual(first); + expect(sorted.invalidEntryPoints[0].missingDependencies).toEqual(['/missing']); + }); + it('should use the appropriate DependencyHost for each entry-point', () => { const esm5Host = new EsmDependencyHost(fs, moduleResolver); const esm2015Host = new EsmDependencyHost(fs, moduleResolver);