Skip to content

Commit

Permalink
perf(core): use ngDevMode to tree-shake checkNoChanges (#39964)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
arturovt authored and mhevery committed Dec 5, 2020
1 parent adeeb84 commit 2fbb684
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion goldens/size-tracking/aio-payloads.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"master": {
"uncompressed": {
"runtime-es2015": 3033,
"main-es2015": 447343,
"main-es2015": 446749,
"polyfills-es2015": 52493
}
}
Expand Down
2 changes: 1 addition & 1 deletion goldens/size-tracking/integration-payloads.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 140899,
"main-es2015": 134899,
"polyfills-es2015": 36571
}
}
Expand Down
7 changes: 3 additions & 4 deletions packages/core/src/application_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,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;

Expand Down Expand Up @@ -602,8 +601,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(() => {
Expand Down Expand Up @@ -740,7 +737,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();
}
Expand Down

0 comments on commit 2fbb684

Please sign in to comment.