perf(core): use `ngDevMode` to tree-shake `checkNoChanges` (#39964)

This commit adds `ngDevMode` guard to run `checkNoChanges` only
in dev mode (similar to how things work in other parts of Ivy runtime code).
The `ngDevMode` flag helps to tree-shake this code from production builds
(in dev mode everything will work as it works right now) to decrease production bundle size.

PR Close #39964
This commit is contained in:
arturovt 2020-12-04 01:00:05 +02:00 committed by Misko Hevery
parent d2042a0da2
commit e1fe9ecffe
3 changed files with 5 additions and 6 deletions

View File

@ -12,7 +12,7 @@
"master": {
"uncompressed": {
"runtime-es2015": 3033,
"main-es2015": 447975,
"main-es2015": 447349,
"polyfills-es2015": 52493
}
}

View File

@ -3,7 +3,7 @@
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 141516,
"main-es2015": 140921,
"polyfills-es2015": 36964
}
}

View File

@ -597,7 +597,6 @@ export class ApplicationRef {
private _bootstrapListeners: ((compRef: ComponentRef<any>) => void)[] = [];
private _views: InternalViewRef[] = [];
private _runningTick: boolean = false;
private _enforceNoNewChanges: boolean = false;
private _stable = true;
private _onMicrotaskEmptySubscription: Subscription;
@ -626,8 +625,6 @@ export class ApplicationRef {
private _exceptionHandler: ErrorHandler,
private _componentFactoryResolver: ComponentFactoryResolver,
private _initStatus: ApplicationInitStatus) {
this._enforceNoNewChanges = isDevMode();
this._onMicrotaskEmptySubscription = this._zone.onMicrotaskEmpty.subscribe({
next: () => {
this._zone.run(() => {
@ -764,7 +761,9 @@ export class ApplicationRef {
for (let view of this._views) {
view.detectChanges();
}
if (this._enforceNoNewChanges) {
// Note that we have still left the `isDevMode()` condition in order to avoid
// creating a breaking change for projects that still use the View Engine.
if ((typeof ngDevMode === 'undefined' || ngDevMode) && isDevMode()) {
for (let view of this._views) {
view.checkNoChanges();
}