fix(ngcc): don't crash on cyclic source-map references (#36452)

The source-map flattening was throwing an error when there
is a cyclic dependency between source files and source-maps.
The error was either a custom one describing the cycle, or a
"Maximum call stack size exceeded" one.

Now this is handled more leniently, resulting in a partially loaded
source file (or source-map) and a warning logged.

Fixes #35727
Fixes #35757
Fixes https://github.com/angular/angular-cli/issues/17106
Fixes https://github.com/angular/angular-cli/issues/17115

PR Close #36452
This commit is contained in:
Pete Bacon Darwin
2020-04-06 13:41:41 +01:00
committed by Kara Erickson
parent 76a8cd57ae
commit ee70a18a75
3 changed files with 153 additions and 71 deletions

View File

@ -36,7 +36,7 @@ export function renderSourceAndMap(
{file: generatedPath, source: generatedPath, includeContent: true});
try {
const loader = new SourceFileLoader(fs);
const loader = new SourceFileLoader(fs, logger);
const generatedFile = loader.loadSourceFile(
generatedPath, generatedContent, {map: generatedMap, mapPath: generatedMapPath});