perf(forms): use `ngDevMode` to tree-shake `_ngModelWarning` (#39964) · angular/angular@735556d · GitHub
Skip to content

Commit 735556d

Browse files
arturovtmhevery
authored andcommitted
perf(forms): use ngDevMode to tree-shake _ngModelWarning (#39964)
This commit adds `ngDevMode` guard to call `_ngModelWarning` only in dev mode (similar to how things work in other parts of Ivy runtime code). The `ngDevMode` flag helps to tree-shake this function from production builds (since it will act as no-op, in dev mode everything will work as it works right now) to decrease production bundle size. PR Close #39964
1 parent 72aad32 commit 735556d

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

packages/forms/src/directives/reactive_directives/form_control_directive.ts

Lines changed: 3 additions & 1 deletion

packages/forms/src/directives/reactive_directives/form_control_name.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ export class FormControlName extends NgControl implements OnChanges, OnDestroy {
145145
ngOnChanges(changes: SimpleChanges) {
146146
if (!this._added) this._setUpControl();
147147
if (isPropertyUpdated(changes, this.viewModel)) {
148-
_ngModelWarning('formControlName', FormControlName, this, this._ngModelWarningConfig);
148+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
149+
_ngModelWarning('formControlName', FormControlName, this, this._ngModelWarningConfig);
150+
}
149151
this.viewModel = this.model;
150152
this.formDirective.updateModel(this, this.model);
151153
}

packages/forms/src/directives/shared.ts

Lines changed: 2 additions & 6 deletions

0 commit comments

Comments
 (0)