Skip to content

Commit 03a3260

Browse files
committed
fix(core): Remove Zone-based change provider from internals by default
This change removes the internally provided `ZoneJS`-based change detection scheduler. This makes Angular Zoneless by default and allows tree-shaking of the Zone change detection providers. BREAKING CHANGE: Angular no longer provides a change detection scheduler for ZoneJS-based change detection by default. Add `provideZoneChangeDetection` to the providers of your `bootstrapApplication` function or your `AppModule` (if using `bootstrapModule`). This provider addition will be covered by an automated migration.
1 parent 1bb30c7 commit 03a3260

File tree

125 files changed

+918
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+918
-298
lines changed

devtools/projects/ng-devtools/src/lib/devtools-tabs/router-tree/router-tree.component.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import SpyObj = jasmine.SpyObj;
1313
import {FrameManager} from '../../application-services/frame_manager';
1414
import {Events, MessageBus} from '../../../../../protocol';
1515
import {ApplicationOperations} from '../../application-operations';
16+
import {provideZoneChangeDetection} from '@angular/core';
1617

1718
describe('RouterTreeComponent', () => {
1819
let messageBus: MessageBus<Events>;
@@ -32,6 +33,7 @@ describe('RouterTreeComponent', () => {
3233
await TestBed.configureTestingModule({
3334
imports: [RouterTreeComponent],
3435
providers: [
36+
provideZoneChangeDetection(),
3537
{provide: ApplicationOperations, useValue: applicationOperationsSpy},
3638
{provide: MessageBus, useValue: messageBus},
3739
{provide: FrameManager, useValue: frameManager},

integration/cli-signal-inputs/src/app/greet.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ describe('greet component', () => {
1111
expect(fixture.nativeElement.textContent).toBe('Initial - initial-unset');
1212

1313
fixture.componentInstance.firstName = 'John';
14+
fixture.changeDetectorRef.markForCheck();
1415
fixture.detectChanges();
1516

1617
expect(fixture.nativeElement.textContent).toBe('John - initial-unset');
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import {provideZoneChangeDetection} from '@angular/core';
12
import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser';
23

34
import {AppComponent} from './app/app.component';
45

56
bootstrapApplication(AppComponent, {
6-
providers: [provideProtractorTestingSupport()],
7+
providers: [provideZoneChangeDetection(), provideProtractorTestingSupport()],
78
});

integration/platform-server/projects/ngmodule/src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {NgModule} from '@angular/core';
1+
import {NgModule, provideZoneChangeDetection} from '@angular/core';
22
import {
33
BrowserModule,
44
provideClientHydration,
@@ -11,7 +11,7 @@ import {AppComponent} from './app.component';
1111
@NgModule({
1212
declarations: [AppComponent],
1313
imports: [BrowserModule, AppRoutingModule],
14-
providers: [provideClientHydration(withIncrementalHydration())],
14+
providers: [provideZoneChangeDetection(), provideClientHydration(withIncrementalHydration())],
1515
bootstrap: [AppComponent],
1616
})
1717
export class AppModule {}

integration/platform-server/projects/standalone/src/app/app.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import {provideClientHydration, withIncrementalHydration} from '@angular/platfor
44
import {provideRouter} from '@angular/router';
55

66
import {routes} from './app.routes';
7+
import {provideZoneChangeDetection} from '@angular/core';
78

89
export const appConfig: ApplicationConfig = {
910
providers: [
11+
provideZoneChangeDetection(),
1012
provideRouter(routes),
1113
provideClientHydration(withIncrementalHydration()),
1214
provideHttpClient(),

modules/benchmarks/src/change_detection/transplanted_views/transplanted_views.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Component,
1414
Input,
1515
NgModule,
16+
provideZoneChangeDetection,
1617
TemplateRef,
1718
ViewChild,
1819
} from '@angular/core';
@@ -67,6 +68,7 @@ export class DeclarationComponent {
6768
@NgModule({
6869
declarations: [DeclarationComponent, InsertionComponent],
6970
bootstrap: [DeclarationComponent],
71+
providers: [provideZoneChangeDetection()],
7072
imports: [BrowserModule],
7173
})
7274
export class TransplantedViewsModule {}

modules/benchmarks/src/defer/baseline/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/pl
1111
import {init, syncUrlParamsToForm} from '../init';
1212

1313
import {AppComponent} from './app.component';
14+
import {provideZoneChangeDetection} from '@angular/core';
1415

1516
syncUrlParamsToForm();
1617

1718
bootstrapApplication(AppComponent, {
18-
providers: [provideProtractorTestingSupport()],
19+
providers: [provideZoneChangeDetection(), provideProtractorTestingSupport()],
1920
}).then(init);

modules/benchmarks/src/defer/main/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser';
10+
import {provideZoneChangeDetection} from '@angular/core';
1011

1112
import {init, syncUrlParamsToForm} from '../init';
1213

@@ -15,5 +16,5 @@ import {AppComponent} from './app.component';
1516
syncUrlParamsToForm();
1617

1718
bootstrapApplication(AppComponent, {
18-
providers: [provideProtractorTestingSupport()],
19+
providers: [provideZoneChangeDetection(), provideProtractorTestingSupport()],
1920
}).then(init);

modules/benchmarks/src/largeform/ng2/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {Component, NgModule} from '@angular/core';
9+
import {Component, NgModule, provideZoneChangeDetection} from '@angular/core';
1010
import {FormsModule} from '@angular/forms';
1111
import {BrowserModule} from '@angular/platform-browser';
1212

@@ -87,5 +87,6 @@ export class AppComponent {
8787
imports: [BrowserModule, FormsModule],
8888
bootstrap: [AppComponent],
8989
declarations: [AppComponent],
90+
providers: [provideZoneChangeDetection()],
9091
})
9192
export class AppModule {}

modules/benchmarks/src/largetable/ng2/main.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {enableProdMode} from '@angular/core';
9+
import {enableProdMode, provideZoneChangeDetection} from '@angular/core';
1010
import {bootstrapApplication} from '@angular/platform-browser';
1111

1212
import {init} from './init';
1313
import {TableComponent} from './table';
1414

1515
enableProdMode();
16-
bootstrapApplication(TableComponent).then(init);
16+
bootstrapApplication(TableComponent, {
17+
providers: [provideZoneChangeDetection()],
18+
}).then(init);

0 commit comments

Comments
 (0)