Skip to content

feat(core): Remove provideZonelessChangeDetection requirement when ZoneJS is not present #62655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Jul 15, 2025

This change updates the internals to provide zoneless scheduling by default when ZoneJS. Developers may still need to use provideZonelessChangeDetection in the providers if the application exists alongside another one that uses ZoneJS (because ZoneJS would then be present and the zone-based change detection scheduler would then be selected). For most applications, this will be sufficient for selecting the correct scheduler without needing the provider.

This is one step towards zoneless by default, but does not yet go as far as removing the provideZoneChangeDetection from the internals. That would/will be larger breaking change since it will require existing Zone-based applications to manually include provideZoneChangeDetection to the application providers (and for all tests).

BREAKING CHANGE: Applications that configure a custom zoneless implementation now and do not want the Angular zoneless scheduler to be enabled will need to include provideZoneChangeDetection as well as a provider for NgZone in the application providers:

bootstrapApplication(App, {providers: [
  provideZoneChangeDetection(),
  {provide: NgZone, useClass: MyNoopNgZone}
]});

@atscott atscott added the target: major This PR is targeted for the next major release label Jul 15, 2025
@angular-robot angular-robot bot added detected: breaking change PR contains a commit with a breaking change detected: feature PR contains a feature commit area: core Issues related to the framework runtime labels Jul 15, 2025
@ngbot ngbot bot added this to the Backlog milestone Jul 15, 2025
@atscott atscott modified the milestones: Backlog, v21 Candidate Jul 15, 2025
…ZoneJS is not present

This change updates the internals to provide zoneless scheduling by
default when ZoneJS. This change means that for most applications,
simply omitting the ZoneJS polyfill will be enough to use zoneless
change detection.

Developers may still need to use `provideZonelessChangeDetection` in the providers if the application
exists alongside another one that uses ZoneJS (because ZoneJS would then
be present and the zone-based change detection scheduler would then be
selected).

This is one step towards zoneless by default, but does not yet go as far
as removing the `provideZoneChangeDetection` from the internals. That
would/will be larger breaking change since it will require existing
Zone-based applications to manually include `provideZoneChangeDetection`
to the application providers (and for all tests).

This approach works well because all existing Zone-based applications
_must_ have ZoneJS already included on the page for them to work. In
addition, this does not affect existing zoneless applications because
they all must already manually use `provideZonelessChangeDetection`
since the only scheduler provided by default prior to this change was
the zone-based one. Only "custom" zoneless (zoneless apps prior to real
zoneless support) may be affected.

BREAKING CHANGE: Applications that configure a custom zoneless implementation
now and _do not_ want the Angular zoneless scheduler to be enabled will
need to include `provideZoneChangeDetection` as well as a provider
for `NgZone` in the application providers:

```
bootstrapApplication(App, {providers: [
  provideZoneChangeDetection(),
  {provide: NgZone, useClass: MyNoopNgZone}
]});
```
@atscott atscott force-pushed the selectSchedulerDynamically branch from 65cea4b to 73a7685 Compare July 15, 2025 21:00
atscott added a commit to atscott/angular-cli that referenced this pull request Jul 15, 2025
This change updates applications to omit the ZoneJS dependency by
default. It depends on angular/angular#62655,
which allows us to also exclude the `provideZonelessChangeDetection`
provider.
atscott added a commit to atscott/angular-cli that referenced this pull request Jul 16, 2025
This change updates applications to omit the ZoneJS dependency by
default. It depends on angular/angular#62655,
which allows us to also exclude the `provideZonelessChangeDetection`
provider.
atscott added a commit to atscott/angular-cli that referenced this pull request Jul 16, 2025
This change updates applications to omit the ZoneJS dependency by
default. It depends on angular/angular#62655,
which allows us to also exclude the `provideZonelessChangeDetection`
provider.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime detected: breaking change PR contains a commit with a breaking change detected: feature PR contains a feature commit target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant