Skip to content

Conversation

@pawelfras
Copy link
Contributor

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the new behavior?

Replaces deprecated ngZoneEventCoalescing with provideZoneChangeDetection({ eventCoalescing: true }) in main.ts.template, to make fresh module-based apps in line with changes from #30718 and angular/angular#63042

Does this PR introduce a breaking change?

  • Yes
  • No

…sed apps to use 'provideZoneChangeDetection'

Replaces deprecated 'ngZoneEventCoalescing' with 'provideZoneChangeDetection({ eventCoalescing: true })' in 'main.ts.template' in schematics for initial commit
platformBrowser().bootstrapModule(AppModule, {
<% if(!zoneless) { %>ngZoneEventCoalescing: true,<% } %><% if(!!viewEncapsulation) { %>
defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } %>
<% if(!zoneless) { %> applicationProviders: [provideZoneChangeDetection({ eventCoalescing: true })], <% } %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This provider should instead go in the module alongside provideBrowserGlobalErrorListeners: packages/schematics/angular/application/files/module-files/src/app/app__typeSeparator__module.ts.template

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @atscott,
thank you for the review and for your comment!
My intention was to make this part of app the fresh module-based app look similar to the result of the bootstrap options migration
The following is an effect of the migration (tested ng20 -> ng21 and ng19 -> ng20 -> ng21):
image

Is there any particular reason why the migration does not remove deprecated ngZoneEventCoalescing and add provideZoneChangeDetection to the app module?

Of course, I'm happy to adjust code in the PR - just asking to get better context.

Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add provideZoneChangeDetection to the app module?

yes. For the migration it is much harder to tell if there was already a change detection provider in the app module somewhere, including one of its imported modules. The migration would have had to instead create a separate module and add it to the imports to ensure it did not override any module providers.

Copy link
Contributor Author

@pawelfras pawelfras Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for sharing the context that helps me understand the decision!
I'll provide the adjustment soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants