fix(ivy): ngcc - handle missing entry-point dependencies better (#30270)

If an entry-point has a missing dependency then all the entry-points
that would have pointed to that dependency are also removed from
the dependency graph.

Previously we were still processing the dependencies of an entry-point
even if it had already been removed from the graph because it depended
upon a missing dependency that had previously been removed due to another
entry-point depending upon it.

This caused the dependency processing to crash rather than gracefully
logging and handling the missing invalid entry-point.

Fixes #29624

PR Close #30270
This commit is contained in:
Pete Bacon Darwin 2019-05-05 14:39:50 +01:00 committed by Kara Erickson
parent f5b2ae616f
commit c59717571e
2 changed files with 7 additions and 5 deletions

View File

@ -128,9 +128,11 @@ export class DependencyResolver {
} else {
dependencies.forEach(dependencyPath => {
if (graph.hasNode(dependencyPath)) {
// The dependency path maps to an entry point that exists in the graph
// so add the dependency.
graph.addDependency(entryPoint.path, dependencyPath);
if (graph.hasNode(entryPoint.path)) {
// The entry-point is still valid (i.e. has no missing dependencies) and
// the dependency maps to an entry point that exists in the graph so add it
graph.addDependency(entryPoint.path, dependencyPath);
}
} else if (invalidEntryPoints.some(i => i.entryPoint.path === dependencyPath)) {
// The dependency path maps to an entry-point that was previously removed
// from the graph, so remove this entry-point as well.

View File

@ -78,7 +78,7 @@ describe('DependencyResolver', () => {
it('should remove entry points that depended upon an invalid entry-point', () => {
spyOn(host, 'findDependencies').and.callFake(createFakeComputeDependencies({
[_('/first/index.js')]: {resolved: [second.path], missing: []},
[_('/first/index.js')]: {resolved: [second.path, third.path], missing: []},
[_('/second/sub/index.js')]: {resolved: [], missing: ['/missing']},
[_('/third/index.js')]: {resolved: [], missing: []},
}));
@ -93,7 +93,7 @@ describe('DependencyResolver', () => {
it('should remove entry points that will depend upon an invalid entry-point', () => {
spyOn(host, 'findDependencies').and.callFake(createFakeComputeDependencies({
[_('/first/index.js')]: {resolved: [second.path], missing: []},
[_('/first/index.js')]: {resolved: [second.path, third.path], missing: []},
[_('/second/sub/index.js')]: {resolved: [], missing: ['/missing']},
[_('/third/index.js')]: {resolved: [], missing: []},
}));