From 0ce8ad3493b48495a5c2782973d45f4b9853b5c1 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Mon, 23 Mar 2020 13:16:36 +0000 Subject: [PATCH] fix(core): workaround Terser inlining bug (#36200) This variable name change works around https://github.com/terser/terser/issues/615, which was causing the JIT production tests to fail in the Angular CLI repository (https://github.com/angular/angular-cli/issues/17264). PR Close #36200 --- packages/core/src/render3/jit/directive.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/core/src/render3/jit/directive.ts b/packages/core/src/render3/jit/directive.ts index e77baf8d46..06398cb75c 100644 --- a/packages/core/src/render3/jit/directive.ts +++ b/packages/core/src/render3/jit/directive.ts @@ -69,19 +69,23 @@ export function compileComponent(type: Type, metadata: Component): void { throw new Error(error.join('\n')); } - const jitOptions = getJitOptions(); + // This const was called `jitOptions` previously but had to be renamed to `options` because + // of a bug with Terser that caused optimized JIT builds to throw a `ReferenceError`. + // This bug was investigated in https://github.com/angular/angular-cli/issues/17264. + // We should not rename it back until https://github.com/terser/terser/issues/615 is fixed. + const options = getJitOptions(); let preserveWhitespaces = metadata.preserveWhitespaces; if (preserveWhitespaces === undefined) { - if (jitOptions !== null && jitOptions.preserveWhitespaces !== undefined) { - preserveWhitespaces = jitOptions.preserveWhitespaces; + if (options !== null && options.preserveWhitespaces !== undefined) { + preserveWhitespaces = options.preserveWhitespaces; } else { preserveWhitespaces = false; } } let encapsulation = metadata.encapsulation; if (encapsulation === undefined) { - if (jitOptions !== null && jitOptions.defaultEncapsulation !== undefined) { - encapsulation = jitOptions.defaultEncapsulation; + if (options !== null && options.defaultEncapsulation !== undefined) { + encapsulation = options.defaultEncapsulation; } else { encapsulation = ViewEncapsulation.Emulated; }