From e1c4930a1a1f2471fabca4b6c8003489cbceed79 Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Fri, 20 Apr 2018 14:53:32 +0200 Subject: [PATCH] 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 --- packages/bazel/src/ngc-wrapped/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/bazel/src/ngc-wrapped/index.ts b/packages/bazel/src/ngc-wrapped/index.ts index 193ce58bc2..c2241f83ff 100644 --- a/packages/bazel/src/ngc-wrapped/index.ts +++ b/packages/bazel/src/ngc-wrapped/index.ts @@ -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