Skip to content

Commit 7258837

Browse files
Pawel Kozlowskialan-agius4
Pawel Kozlowski
authored andcommittedMar 29, 2024
feat(@schematics/angular): use eventCoalescing option by default (standalone bootstrap)
This commit enables eventCoalescing by default for standalone applications.
1 parent fc7d796 commit 7258837

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { ApplicationConfig } from '@angular/core';<% if (routing) { %>
1+
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';<% if (routing) { %>
22
import { provideRouter } from '@angular/router';
33

44
import { routes } from './app.routes';<% } %>
55

66
export const appConfig: ApplicationConfig = {
7-
providers: [<% if (routing) { %>provideRouter(routes)<% } %>]
7+
providers: [provideZoneChangeDetection({eventCoalescing: true})<% if (routing) { %>, provideRouter(routes)<% } %>]
88
};

Diff for: ‎packages/schematics/angular/server/index_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe('Server Schematic', () => {
138138
it(`should add 'provideClientHydration' to the providers list`, async () => {
139139
const tree = await schematicRunner.runSchematic('server', defaultOptions, appTree);
140140
const contents = tree.readContent('/projects/bar/src/app/app.config.ts');
141-
expect(contents).toContain(`providers: [provideClientHydration()]`);
141+
expect(contents).toContain(`provideClientHydration()`);
142142
});
143143
});
144144

Diff for: ‎packages/schematics/angular/service-worker/index_spec.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,19 @@ describe('Service Worker Schematic', () => {
128128
const tree = await schematicRunner.runSchematic('service-worker', defaultOptions, appTree);
129129
const content = tree.readContent('/projects/bar/src/app/app.config.ts');
130130
expect(tags.oneLine`${content}`).toContain(tags.oneLine`
131-
providers: [provideServiceWorker('ngsw-worker.js', {
132-
enabled: !isDevMode(),
133-
registrationStrategy: 'registerWhenStable:30000'
134-
})]
131+
provideServiceWorker('ngsw-worker.js', {
132+
enabled: !isDevMode(),
133+
registrationStrategy: 'registerWhenStable:30000'
134+
})
135135
`);
136136
});
137137

138138
it(`should import 'isDevMode' from '@angular/core'`, async () => {
139139
const tree = await schematicRunner.runSchematic('service-worker', defaultOptions, appTree);
140140
const content = tree.readContent('/projects/bar/src/app/app.config.ts');
141-
expect(content).toContain(`import { ApplicationConfig, isDevMode } from '@angular/core';`);
141+
expect(content).toContain(
142+
`import { ApplicationConfig, provideZoneChangeDetection, isDevMode } from '@angular/core';`,
143+
);
142144
});
143145

144146
it(`should import 'provideServiceWorker' from '@angular/service-worker'`, async () => {

Diff for: ‎packages/schematics/angular/utility/standalone/rules_spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,9 @@ describe('standalone utilities', () => {
9393

9494
const content = readFile('app/app.config.ts');
9595

96-
assertContains(
97-
content,
98-
`import { ApplicationConfig, importProvidersFrom } from '@angular/core';`,
99-
);
96+
assertContains(content, `importProvidersFrom`);
10097
assertContains(content, `import { MyModule } from '@my/module';`);
101-
assertContains(content, `providers: [importProvidersFrom(MyModule)]`);
98+
assertContains(content, `importProvidersFrom(MyModule)`);
10299
});
103100

104101
it('should add a root import to a standalone app whose app config does not have a providers array', async () => {
@@ -443,7 +440,10 @@ describe('standalone utilities', () => {
443440
const content = readFile('app/app.config.ts');
444441

445442
assertContains(content, `import { provideModule } from '@my/module';`);
446-
assertContains(content, `providers: [provideModule([])]`);
443+
assertContains(
444+
content,
445+
`providers: [provideZoneChangeDetection({eventCoalescing:true}),provideModule([])]`,
446+
);
447447
});
448448

449449
it('should add a root provider to a standalone app when providers contain a trailing comma', async () => {

0 commit comments

Comments
 (0)
Please sign in to comment.