Skip to content

Commit 33f7cf7

Browse files
pawelfrashybrist
authored andcommitted
fix(@schematics/angular): update application schematics for module-based apps to use 'provideZoneChangeDetection'
Replaces deprecated 'ngZoneEventCoalescing' with 'provideZoneChangeDetection({ eventCoalescing: true })' in 'main.ts.template' in schematics for initial commit (cherry picked from commit 42d4feb)
1 parent 2495637 commit 33f7cf7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<% if(!!viewEncapsulation) { %>import { ViewEncapsulation } from '@angular/core';
2+
<% }%><% if(!zoneless) { %>import { provideZoneChangeDetection } from '@angular/core';
23
<% }%>import { platformBrowser } from '@angular/platform-browser';
34
import { AppModule } from './app/app<%= typeSeparator %>module';
45

56
platformBrowser().bootstrapModule(AppModule, {
6-
<% if(!zoneless) { %>ngZoneEventCoalescing: true,<% } %><% if(!!viewEncapsulation) { %>
7-
defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } %>
7+
<% if(!zoneless) { %> applicationProviders: [provideZoneChangeDetection({ eventCoalescing: true })], <% } %>
8+
<% if(!!viewEncapsulation) { %> defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } %>
89
})
910
.catch(err => console.error(err));

packages/schematics/angular/application/index_spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ describe('Application Schematic', () => {
687687
});
688688

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

701701
const content = tree.readContent('/projects/foo/src/main.ts');
702-
expect(content).toContain('ngZoneEventCoalescing: true');
702+
expect(content).toContain(
703+
'applicationProviders: [provideZoneChangeDetection({ eventCoalescing: true })]',
704+
);
703705
});
704706

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

0 commit comments

Comments
 (0)