From f022efa06f0ef3379d7bcdb5ecadf44daa366818 Mon Sep 17 00:00:00 2001 From: arturovt Date: Fri, 4 Dec 2020 11:23:58 +0200 Subject: [PATCH] perf(common): use `ngDevMode` to tree-shake warnings (#39964) This commit adds ngDevMode guard to show warnings only in dev mode (similar to how things work in other parts of Ivy runtime code). The ngDevMode flag helps to tree-shake these warnings from production builds (in dev mode everything will work as it works right now) to decrease production bundle size. PR Close #39964 --- packages/common/src/directives/ng_for_of.ts | 4 ++-- packages/common/src/pipes/number_pipe.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/common/src/directives/ng_for_of.ts b/packages/common/src/directives/ng_for_of.ts index bae7bd543d2..597937d3276 100644 --- a/packages/common/src/directives/ng_for_of.ts +++ b/packages/common/src/directives/ng_for_of.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, DoCheck, EmbeddedViewRef, Input, isDevMode, IterableChangeRecord, IterableChanges, IterableDiffer, IterableDiffers, NgIterable, TemplateRef, TrackByFunction, ViewContainerRef} from '@angular/core'; +import {Directive, DoCheck, EmbeddedViewRef, Input, IterableChangeRecord, IterableChanges, IterableDiffer, IterableDiffers, NgIterable, TemplateRef, TrackByFunction, ViewContainerRef} from '@angular/core'; /** * @publicApi @@ -159,7 +159,7 @@ export class NgForOf = NgIterable> implements DoCh */ @Input() set ngForTrackBy(fn: TrackByFunction) { - if (isDevMode() && fn != null && typeof fn !== 'function') { + if ((typeof ngDevMode === 'undefined' || ngDevMode) && fn != null && typeof fn !== 'function') { // TODO(vicb): use a log service once there is a public one available if (console && console.warn) { console.warn( diff --git a/packages/common/src/pipes/number_pipe.ts b/packages/common/src/pipes/number_pipe.ts index edc6d080949..4c1c54ff55f 100644 --- a/packages/common/src/pipes/number_pipe.ts +++ b/packages/common/src/pipes/number_pipe.ts @@ -241,7 +241,7 @@ export class CurrencyPipe implements PipeTransform { locale = locale || this._locale; if (typeof display === 'boolean') { - if (console && console.warn) { + if ((typeof ngDevMode === 'undefined' || ngDevMode) && console && console.warn) { console.warn( `Warning: the currency pipe has been changed in Angular v5. The symbolDisplay option (third parameter) is now a string instead of a boolean. The accepted values are "code", "symbol" or "symbol-narrow".`); }