fix(ivy): ngcc - don't crash if entry-points have multiple invalid dependencies (#31276)

If an entry-point has missing dependencies then it cannot be
processed and is marked as invalid. Similarly, if an entry-point
has dependencies that have been marked as invalid then that
entry-point too is invalid. In all these cases, ngcc should quietly
ignore these entry-points and continue processing what it can.

Previously, if an entry-point had more than one entry-point that
was transitively invalid then ngcc was crashing rather than
ignoring the entry-point.

PR Close #31276
This commit is contained in:
Pete Bacon Darwin
2019-06-26 09:16:15 +01:00
committed by Kara Erickson
parent 32c760f5e7
commit 3788ebb714
2 changed files with 22 additions and 6 deletions

View File

@ -125,6 +125,21 @@ runInEachFileSystem(() => {
]);
});
it('should cope with entry points having multiple indirect missing dependencies', () => {
spyOn(host, 'findDependencies').and.callFake(createFakeComputeDependencies({
[_('/first/index.js')]: {resolved: [], missing: ['/missing1']},
[_('/second/sub/index.js')]: {resolved: [], missing: ['/missing2']},
[_('/third/index.js')]: {resolved: [first.path, second.path], missing: []},
}));
const result = resolver.sortEntryPointsByDependency([first, second, third]);
expect(result.entryPoints).toEqual([]);
expect(result.invalidEntryPoints).toEqual([
{entryPoint: first, missingDependencies: ['/missing1']},
{entryPoint: second, missingDependencies: ['/missing2']},
{entryPoint: third, missingDependencies: [first.path]},
]);
});
it('should error if the entry point does not have a suitable format', () => {
expect(() => resolver.sortEntryPointsByDependency([
{ path: '/first', packageJson: {}, compiledByAngular: true } as EntryPoint