10000 perf(core): use `ngDevMode` to tree-shake `checkNoChanges` (#39964) · angular/angular@2fbb684 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2fbb684

Browse files
arturovtmhevery
authored andcommitted
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
1 parent adeeb84 commit 2fbb684

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

goldens/size-tracking/aio-payloads.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"master": {
1313
"uncompressed": {
1414
"runtime-es2015": 3033,
15-
"main-es2015": 447343,
15+
"main-es2015": 446749,
1616
"polyfills-es2015": 52493
1717
}
1818
}

goldens/size-tracking/integration-payloads.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"master": {
44
"uncompressed": {
55
"runtime-es2015": 1485,
6-
"main-es2015": 140899,
6+
"main-es2015": 134899,
77
"polyfills-es2015": 36571
88
}
99
}

packages/core/src/application_ref.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@ export class ApplicationRef {
573573
private _bootstrapListeners: ((compRef: ComponentRef<any>) => void)[] = [];
574574
private _views: InternalViewRef[] = [];
575575
private _runningTick: boolean = false;
576-
private _enforceNoNewChanges: boolean = false;
577576
private _stable = true;
578577
private _onMicrotaskEmptySubscription: Subscription;
579578

@@ -602,8 +601,6 @@ export class ApplicationRef {
602601
private _exceptionHandler: ErrorHandler,
603602
private _componentFactoryResolver: ComponentFactoryResolver,
604603
private _initStatus: ApplicationInitStatus) {
605-
this._enforceNoNewChanges = isDevMode();
606-
607604
this._onMicrotaskEmptySubscription = this._zone.onMicrotaskEmpty.subscribe({
608605
next: () => {
609606
this._zone.run(() => {
@@ -740,7 +737,9 @@ export class ApplicationRef {
740737
for (let view of this._views) {
741738
view.detectChanges();
742739
}
743-
if (this._enforceNoNewChanges) {
740+
// Note that we have still left the `isDevMode()` condition in order to avoid
741+
// creating a breaking change for projects that still use the View Engine.
742+
if ((typeof ngDevMode === 'undefined' || ngDevMode) && isDevMode()) {
744743
for (let view of this._views) {
745744
view.checkNoChanges();
746745
}

0 commit comments

Comments
 (0)
0