Skip to content

Commit cfca544

Browse files
committed
feat(@schematics/angular): integrate withEventReplay() in provideClientHydration for new SSR apps
Event Replay is now stable (see angular/angular#57895). This commit adds `withEventReplay()` to the `provideClientHydration()` call in newly created Angular applications with SSR.
1 parent 26962e4 commit cfca544

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/schematics/angular/server/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import { JsonValue, Path, basename, dirname, join, normalize } from '@angular-devkit/core';
1010
import {
1111
Rule,
12-
SchematicContext,
1312
SchematicsException,
1413
Tree,
1514
apply,
@@ -222,7 +221,10 @@ export default function (options: ServerOptions): Rule {
222221
addRootProvider(
223222
options.project,
224223
({ code, external }) =>
225-
code`${external('provideClientHydration', '@angular/platform-browser')}()`,
224+
code`${external('provideClientHydration', '@angular/platform-browser')}(${external(
225+
'withEventReplay',
226+
'@angular/platform-browser',
227+
)}())`,
226228
),
227229
]);
228230
};

packages/schematics/angular/server/index_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('Server Schematic', () => {
9595
it(`should add 'provideClientHydration' to the providers list`, async () => {
9696
const tree = await schematicRunner.runSchematic('server', defaultOptions, appTree);
9797
const contents = tree.readContent('/projects/bar/src/app/app.module.ts');
98-
expect(contents).toContain(`provideClientHydration()`);
98+
expect(contents).toContain(`provideClientHydration(withEventReplay())`);
9999
});
100100
});
101101

@@ -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(`provideClientHydration()`);
141+
expect(contents).toContain(`provideClientHydration(withEventReplay())`);
142142
});
143143
});
144144

0 commit comments

Comments
 (0)