fix(compiler): avoid a crash in ngc-wrapped. (#23468)

`ng.performCompilation` can return an `undefined` program, which is not handled by ngc-wrapped.

Avoid crashing by checking for the error return and returning the diagnostics.
PR Close #23468
This commit is contained in:
Martin Probst 2018-04-20 14:53:32 +02:00 committed by Victor Berchet
parent dab5df9734
commit e1c4930a1a
1 changed files with 4 additions and 0 deletions

View File

@ -267,6 +267,10 @@ export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true,
fs.writeFileSync(bazelOpts.manifest, manifest);
}
}
// If compilation fails unexpectedly, performCompilation returns no program.
// Make sure not to crash but report the diagnostics.
if (!program) return {program, diagnostics};
if (!bazelOpts.nodeModulesPrefix) {
// If there is no node modules, then metadata.json should be emitted since