From 70b4816cd5fd51cfabd699c4c1cda51feaa1fa72 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 15 Dec 2020 11:04:47 +0100 Subject: [PATCH] fix(core): set `ngDevMode` to `false` when calling `enableProdMode()` (#40124) The `ngDevMode` description also mentions that calling `enableProdMode` will set this the value to `false`. https://github.com/angular/angular/blob/4610093c87975b6355f31a9c849351129908783a/packages/core/src/util/ng_dev_mode.ts#L22 which is currently not the case. PR Close #40124 --- packages/core/src/util/is_dev_mode.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/core/src/util/is_dev_mode.ts b/packages/core/src/util/is_dev_mode.ts index 8f3d530fae..ad8184c922 100644 --- a/packages/core/src/util/is_dev_mode.ts +++ b/packages/core/src/util/is_dev_mode.ts @@ -6,6 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ +import {global} from './global'; + /** * This file is used to control if the default rendering pipeline should be `ViewEngine` or `Ivy`. * @@ -44,5 +46,12 @@ export function enableProdMode(): void { if (_runModeLocked) { throw new Error('Cannot enable prod mode after platform setup.'); } + + // The below check is there so when ngDevMode is set via terser + // `global['ngDevMode'] = false;` is also dropped. + if (typeof ngDevMode === undefined || !!ngDevMode) { + global['ngDevMode'] = false; + } + _devMode = false; }