Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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,4 +1,4 @@
import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core';
import { NgModule, provideBrowserGlobalErrorListeners<% if(!zoneless) { %>, provideZoneChangeDetection<% } %> } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
<% if (routing) { %>
import { AppRoutingModule } from './app-routing<%= typeSeparator %>module';<% } %>
Expand All @@ -13,7 +13,8 @@ import { App } from './app<%= suffix %>';
AppRoutingModule<% } %>
],
providers: [
provideBrowserGlobalErrorListeners()
provideBrowserGlobalErrorListeners(),<% if(!zoneless) { %>
provideZoneChangeDetection({ eventCoalescing: true }),<% } %>
],
bootstrap: [App]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { AppModule } from './app/app<%= typeSeparator %>module';

platformBrowser().bootstrapModule(AppModule, {
<% if(!zoneless) { %>ngZoneEventCoalescing: true,<% } %><% if(!!viewEncapsulation) { %>
defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } %>
<% if(!!viewEncapsulation) { %> defaultEncapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } %>
})
.catch(err => console.error(err));
17 changes: 14 additions & 3 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 @@ -698,8 +698,8 @@ describe('Application Schematic', () => {
workspaceTree,
);

const content = tree.readContent('/projects/foo/src/main.ts');
expect(content).toContain('ngZoneEventCoalescing: true');
const content = tree.readContent('/projects/foo/src/app/app-module.ts');
expect(content).toContain('provideZoneChangeDetection({ eventCoalescing: true })');
});

it(`should set 'defaultEncapsulation' in main.ts when 'ViewEncapsulation' is provided`, async () => {
Expand Down Expand Up @@ -890,6 +890,17 @@ describe('Application Schematic', () => {
});

describe('standalone: false', () => {
it('should add the provideZoneChangeDetection with event coalescing option by default with zone.js apps', async () => {
const options = {
...defaultOptions,
standalone: false,
zoneless: false,
fileNameStyleGuide: '2016' as const,
};
const tree = await schematicRunner.runSchematic('application', options, workspaceTree);
const content = tree.readContent('/projects/foo/src/app/app.module.ts');
expect(content).toContain('provideZoneChangeDetection({ eventCoalescing: true })');
});
it('should create a component with the correct template and style urls', async () => {
const options = {
...defaultOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ describe('standalone utilities', () => {
assertContains(content, `import { SOME_TOKEN } from '@my/module';`);
assertContains(
content,
`providers: [provideBrowserGlobalErrorListeners(),{ provide: SOME_TOKEN, useValue: 123 }]`,
`providers: [provideBrowserGlobalErrorListeners(),{ provide: SOME_TOKEN, useValue: 123 },]`,
);
});

Expand Down