Skip to content

Commit

Permalink
perf(common): use ngDevMode to tree-shake warnings (#39964)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
arturovt authored and mhevery committed Dec 5, 2020
1 parent 2fbb684 commit bf3de9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/common/src/directives/ng_for_of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -159,7 +159,7 @@ export class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCh
*/
@Input()
set ngForTrackBy(fn: TrackByFunction<T>) {
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 (<any>console && <any>console.warn) {
console.warn(
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/pipes/number_pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class CurrencyPipe implements PipeTransform {
locale = locale || this._locale;

if (typeof display === 'boolean') {
if (<any>console && <any>console.warn) {
if ((typeof ngDevMode === 'undefined' || ngDevMode) && <any>console && <any>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".`);
}
Expand Down

0 comments on commit bf3de9b

Please sign in to comment.