Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<% if(!!viewEncapsulation) { %>import { ViewEncapsulation } from '@angular/core';
<% }%><% if(!zoneless) { %>import { provideZoneChangeDetection } from '@angular/core';
<% }%>import { platformBrowser } from '@angular/platform-browser';
import { AppModule } from './app/app<%= typeSeparator %>module';

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@atscott changes pushed 👍
I'd appreciate a review.

<% if(!!viewEncapsulation) { %> defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } %>
})
.catch(err => console.error(err));
6 changes: 4 additions & 2 deletions packages/schematics/angular/application/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ describe('Application Schematic', () => {
});

describe('standalone=false', () => {
it('should add the ngZoneEventCoalescing option by default with zone.js apps', async () => {
it('should add the provideZoneChangeDetection with event coalescing option by default with zone.js apps', async () => {
const tree = await schematicRunner.runSchematic(
'application',
{
Expand All @@ -699,7 +699,9 @@ describe('Application Schematic', () => {
);

const content = tree.readContent('/projects/foo/src/main.ts');
expect(content).toContain('ngZoneEventCoalescing: true');
expect(content).toContain(
'applicationProviders: [provideZoneChangeDetection({ eventCoalescing: true })]',
);
});

it(`should set 'defaultEncapsulation' in main.ts when 'ViewEncapsulation' is provided`, async () => {
Expand Down