Skip to content

Commit bbbc1eb

Browse files
committedJan 28, 2025·
fix(@angular/ssr): rename provideServerRoutesConfig to provideServerRouting
This commit renames `provideServerRoutesConfig` to `provideServerRouting` and updates the second parameter to use the `ServerRoutes` features. This change improves alignment with the framework's API conventions and the way features are integrated. ### Example Usage: Before: ```typescript provideServerRoutesConfig(serverRoutes, { appShellRoute: 'shell' }) ``` After: ```typescript provideServerRouting(serverRoutes, withAppShell(AppShellComponent)) ``` (cherry picked from commit ec05c81)
1 parent 14ab097 commit bbbc1eb

File tree

8 files changed

+204
-196
lines changed

8 files changed

+204
-196
lines changed
 

‎goldens/public-api/angular/ssr/index.api.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
55
```ts
66

7+
import { DefaultExport } from '@angular/router';
78
import { EnvironmentProviders } from '@angular/core';
9+
import { Provider } from '@angular/core';
10+
import { Type } from '@angular/core';
811

912
// @public
1013
export class AngularAppEngine {
@@ -23,9 +26,12 @@ export enum PrerenderFallback {
2326
Server = 0
2427
}
2528

26-
// @public
29+
// @public @deprecated
2730
export function provideServerRoutesConfig(routes: ServerRoute[], options?: ServerRoutesConfigOptions): EnvironmentProviders;
2831

32+
// @public
33+
export function provideServerRouting(routes: ServerRoute[], ...features: ServerRoutesFeature<ServerRoutesFeatureKind>[]): EnvironmentProviders;
34+
2935
// @public
3036
export enum RenderMode {
3137
Client = 1,
@@ -63,7 +69,7 @@ export interface ServerRoutePrerenderWithParams extends Omit<ServerRoutePrerende
6369
getPrerenderParams: () => Promise<Record<string, string>[]>;
6470
}
6571

66-
// @public
72+
// @public @deprecated
6773
export interface ServerRoutesConfigOptions {
6874
appShellRoute?: string;
6975
}
@@ -73,6 +79,9 @@ export interface ServerRouteServer extends ServerRouteCommon {
7379
renderMode: RenderMode.Server;
7480
}
7581

82+
// @public
83+
export function withAppShell(component: Type<unknown> | (() => Promise<Type<unknown> | DefaultExport<Type<unknown>>>)): ServerRoutesFeature<ServerRoutesFeatureKind.AppShell>;
84+
7685
// (No @packageDocumentation comment for this package)
7786

7887
```

‎packages/angular/ssr/public_api.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export {
1616
type ServerRoute,
1717
type ServerRoutesConfigOptions,
1818
provideServerRoutesConfig,
19+
provideServerRouting,
20+
withAppShell,
1921
RenderMode,
2022
type ServerRouteClient,
2123
type ServerRoutePrerender,

‎packages/angular/ssr/src/routes/route-config.ts

+127-8
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,43 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';
9+
import {
10+
EnvironmentProviders,
11+
InjectionToken,
12+
Provider,
13+
Type,
14+
makeEnvironmentProviders,
15+
} from '@angular/core';
16+
import { type DefaultExport, ROUTES, type Route } from '@angular/router';
17+
18+
/**
19+
* The internal path used for the app shell route.
20+
* @internal
21+
*/
22+
const APP_SHELL_ROUTE = 'ng-app-shell';
23+
24+
/**
25+
* Identifies a particular kind of `ServerRoutesFeatureKind`.
26+
* @see {@link ServerRoutesFeature}
27+
* @developerPreview
28+
*/
29+
enum ServerRoutesFeatureKind {
30+
AppShell,
31+
}
32+
33+
/**
34+
* Helper type to represent a server routes feature.
35+
* @see {@link ServerRoutesFeatureKind}
36+
* @developerPreview
37+
*/
38+
interface ServerRoutesFeature<FeatureKind extends ServerRoutesFeatureKind> {
39+
ɵkind: FeatureKind;
40+
ɵproviders: Provider[];
41+
}
1042

1143
/**
1244
* Different rendering modes for server routes.
13-
* @see {@link provideServerRoutesConfig}
45+
* @see {@link provideServerRouting}
1446
* @see {@link ServerRoute}
1547
* @developerPreview
1648
*/
@@ -148,7 +180,7 @@ export interface ServerRouteServer extends ServerRouteCommon {
148180

149181
/**
150182
* Server route configuration.
151-
* @see {@link provideServerRoutesConfig}
183+
* @see {@link provideServerRouting}
152184
* @developerPreview
153185
*/
154186
export type ServerRoute =
@@ -163,17 +195,16 @@ export type ServerRoute =
163195
* This interface defines the optional settings available for configuring server routes
164196
* in the server-side environment, such as specifying a path to the app shell route.
165197
*
166-
* @see {@link provideServerRoutesConfig}
167-
* @developerPreview
198+
*
199+
* @see {@link provideServerRouting}
200+
* @deprecated use `provideServerRouting`. This will be removed in version 20.
168201
*/
169202

170203
export interface ServerRoutesConfigOptions {
171204
/**
172205
* Defines the route to be used as the app shell, which serves as the main entry
173206
* point for the application. This route is often used to enable server-side rendering
174207
* of the application shell for requests that do not match any specific server route.
175-
*
176-
* @see {@link https://angular.dev/ecosystem/service-workers/app-shell | App shell pattern on Angular.dev}
177208
*/
178209
appShellRoute?: string;
179210
}
@@ -182,7 +213,13 @@ export interface ServerRoutesConfigOptions {
182213
* Configuration value for server routes configuration.
183214
* @internal
184215
*/
185-
export interface ServerRoutesConfig extends ServerRoutesConfigOptions {
216+
export interface ServerRoutesConfig {
217+
/**
218+
* Defines the route to be used as the app shell.
219+
*/
220+
appShellRoute?: string;
221+
222+
/** List of server routes for the application. */
186223
routes: ServerRoute[];
187224
}
188225

@@ -204,6 +241,8 @@ export const SERVER_ROUTES_CONFIG = new InjectionToken<ServerRoutesConfig>('SERV
204241
*
205242
* @see {@link ServerRoute}
206243
* @see {@link ServerRoutesConfigOptions}
244+
* @see {@link provideServerRouting}
245+
* @deprecated use `provideServerRouting`. This will be removed in version 20.
207246
* @developerPreview
208247
*/
209248
export function provideServerRoutesConfig(
@@ -223,3 +262,83 @@ export function provideServerRoutesConfig(
223262
},
224263
]);
225264
}
265+
266+
/**
267+
* Sets up the necessary providers for configuring server routes.
268+
* This function accepts an array of server routes and optional configuration
269+
* options, returning an `EnvironmentProviders` object that encapsulates
270+
* the server routes and configuration settings.
271+
*
272+
* @param routes - An array of server routes to be provided.
273+
* @param features - (Optional) server routes features.
274+
* @returns An `EnvironmentProviders` instance with the server routes configuration.
275+
*
276+
* @see {@link ServerRoute}
277+
* @see {@link withAppShell}
278+
* @developerPreview
279+
*/
280+
export function provideServerRouting(
281+
routes: ServerRoute[],
282+
...features: ServerRoutesFeature<ServerRoutesFeatureKind>[]
283+
): EnvironmentProviders {
284+
const config: ServerRoutesConfig = { routes };
285+
const hasAppShell = features.some((f) => f.ɵkind === ServerRoutesFeatureKind.AppShell);
286+
if (hasAppShell) {
287+
config.appShellRoute = APP_SHELL_ROUTE;
288+
}
289+
290+
const providers: Provider[] = [
291+
{
292+
provide: SERVER_ROUTES_CONFIG,
293+
useValue: config,
294+
},
295+
];
296+
297+
for (const feature of features) {
298+
providers.push(...feature.ɵproviders);
299+
}
300+
301+
return makeEnvironmentProviders(providers);
302+
}
303+
304+
/**
305+
* Configures the app shell route with the provided component.
306+
*
307+
* The app shell serves as the main entry point for the application and is commonly used
308+
* to enable server-side rendering (SSR) of the application shell. It handles requests
309+
* that do not match any specific server route, providing a fallback mechanism and improving
310+
* perceived performance during navigation.
311+
*
312+
* This configuration is particularly useful in applications leveraging Progressive Web App (PWA)
313+
* patterns, such as service workers, to deliver a seamless user experience.
314+
*
315+
* @param component The Angular component to render for the app shell route.
316+
* @returns A server routes feature configuration for the app shell.
317+
*
318+
* @see {@link provideServerRouting}
319+
* @see {@link https://angular.dev/ecosystem/service-workers/app-shell | App shell pattern on Angular.dev}
320+
*/
321+
export function withAppShell(
322+
component: Type<unknown> | (() => Promise<Type<unknown> | DefaultExport<Type<unknown>>>),
323+
): ServerRoutesFeature<ServerRoutesFeatureKind.AppShell> {
324+
const routeConfig: Route = {
325+
path: APP_SHELL_ROUTE,
326+
};
327+
328+
if ('ɵcmp' in component) {
329+
routeConfig.component = component as Type<unknown>;
330+
} else {
331+
routeConfig.loadComponent = component as () => Promise<Type<unknown>>;
332+
}
333+
334+
return {
335+
ɵkind: ServerRoutesFeatureKind.AppShell,
336+
ɵproviders: [
337+
{
338+
provide: ROUTES,
339+
useValue: routeConfig,
340+
multi: true,
341+
},
342+
],
343+
};
344+
}

‎packages/angular/ssr/test/testing-utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { provideServerRendering } from '@angular/platform-server';
1818
import { RouterOutlet, Routes, provideRouter } from '@angular/router';
1919
import { destroyAngularServerApp } from '../src/app';
2020
import { ServerAsset, setAngularAppManifest } from '../src/manifest';
21-
import { ServerRoute, provideServerRoutesConfig } from '../src/routes/route-config';
21+
import { ServerRoute, provideServerRouting } from '../src/routes/route-config';
2222

2323
@Component({
2424
standalone: true,
@@ -97,7 +97,7 @@ export function setAngularAppTestingManifest(
9797
provideServerRendering(),
9898
provideExperimentalZonelessChangeDetection(),
9999
provideRouter(routes),
100-
provideServerRoutesConfig(serverRoutes),
100+
provideServerRouting(serverRoutes),
101101
...extraProviders,
102102
],
103103
});

‎packages/schematics/angular/app-shell/index.ts

+56-81
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
import { dirname, join } from 'node:path/posix';
1818
import ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescript';
1919
import {
20-
addImportToModule,
2120
addSymbolToNgModuleMetadata,
2221
findNode,
2322
findNodes,
@@ -140,19 +139,6 @@ function validateProject(mainPath: string): Rule {
140139
};
141140
}
142141

143-
function addRouterModule(mainPath: string): Rule {
144-
return (host: Tree) => {
145-
const modulePath = getAppModulePath(host, mainPath);
146-
const moduleSource = getSourceFile(host, modulePath);
147-
const changes = addImportToModule(moduleSource, modulePath, 'RouterModule', '@angular/router');
148-
const recorder = host.beginUpdate(modulePath);
149-
applyToUpdateRecorder(recorder, changes);
150-
host.commitUpdate(recorder);
151-
152-
return host;
153-
};
154-
}
155-
156142
function getMetadataProperty(metadata: ts.Node, propertyName: string): ts.PropertyAssignment {
157143
const properties = (metadata as ts.ObjectLiteralExpression).properties;
158144
const property = properties.filter(ts.isPropertyAssignment).filter((prop) => {
@@ -265,7 +251,7 @@ function addStandaloneServerRoute(options: AppShellOptions): Rule {
265251
throw new SchematicsException(`Cannot find "${configFilePath}".`);
266252
}
267253

268-
let recorder = host.beginUpdate(configFilePath);
254+
const recorder = host.beginUpdate(configFilePath);
269255
let configSourceFile = getSourceFile(host, configFilePath);
270256
if (!isImported(configSourceFile, 'ROUTES', '@angular/router')) {
271257
const routesChange = insertImport(
@@ -295,89 +281,74 @@ function addStandaloneServerRoute(options: AppShellOptions): Rule {
295281
const updatedProvidersString = [
296282
...providersLiteral.elements.map((element) => ' ' + element.getText()),
297283
` {
298-
provide: ROUTES,
299-
multi: true,
300-
useValue: [{
301-
path: '${APP_SHELL_ROUTE}',
302-
component: AppShellComponent
303-
}]
304-
}\n `,
284+
provide: ROUTES,
285+
multi: true,
286+
useValue: [{
287+
path: '${APP_SHELL_ROUTE}',
288+
component: AppShellComponent
289+
}]
290+
}\n `,
305291
];
306292

307293
recorder.insertRight(providersLiteral.getStart(), `[\n${updatedProvidersString.join(',\n')}]`);
308294

309-
if (options.serverRouting) {
310-
host.commitUpdate(recorder);
311-
configSourceFile = getSourceFile(host, configFilePath);
312-
const functionCall = findNodes(configSourceFile, ts.isCallExpression).find(
313-
(n) =>
314-
ts.isIdentifier(n.expression) && n.expression.getText() === 'provideServerRoutesConfig',
315-
);
316-
317-
if (!functionCall) {
318-
throw new SchematicsException(
319-
`Cannot find the "provideServerRoutesConfig" function call in "${configFilePath}".`,
320-
);
321-
}
322-
323-
recorder = host.beginUpdate(configFilePath);
324-
recorder.insertLeft(functionCall.end - 1, `, { appShellRoute: '${APP_SHELL_ROUTE}' }`);
325-
}
326-
327-
// Add AppShellComponent import
328-
const appShellImportChange = insertImport(
329-
configSourceFile,
330-
configFilePath,
331-
'AppShellComponent',
332-
'./app-shell/app-shell.component',
333-
);
334-
335-
applyToUpdateRecorder(recorder, [appShellImportChange]);
295+
applyToUpdateRecorder(recorder, [
296+
insertImport(
297+
configSourceFile,
298+
configFilePath,
299+
'AppShellComponent',
300+
'./app-shell/app-shell.component',
301+
),
302+
]);
336303
host.commitUpdate(recorder);
337304
};
338305
}
339306

340-
function addServerRoutingConfig(options: AppShellOptions): Rule {
307+
function addServerRoutingConfig(options: AppShellOptions, isStandalone: boolean): Rule {
341308
return async (host: Tree) => {
342309
const workspace = await getWorkspace(host);
343310
const project = workspace.projects.get(options.project);
344311
if (!project) {
345312
throw new SchematicsException(`Project name "${options.project}" doesn't not exist.`);
346313
}
347314

348-
const configFilePath = join(project.sourceRoot ?? 'src', 'app/app.routes.server.ts');
349-
if (!host.exists(configFilePath)) {
315+
const configFilePath = isStandalone
316+
? join(project.sourceRoot ?? 'src', 'app/app.config.server.ts')
317+
: getServerModulePath(host, project.sourceRoot || 'src', 'main.server.ts');
318+
319+
if (!configFilePath || !host.exists(configFilePath)) {
350320
throw new SchematicsException(`Cannot find "${configFilePath}".`);
351321
}
352322

353-
const sourceFile = getSourceFile(host, configFilePath);
354-
const nodes = getSourceNodes(sourceFile);
355-
356-
// Find the serverRoutes variable declaration
357-
const serverRoutesNode = nodes.find(
358-
(node) =>
359-
ts.isVariableDeclaration(node) &&
360-
node.initializer &&
361-
ts.isArrayLiteralExpression(node.initializer) &&
362-
node.type &&
363-
ts.isArrayTypeNode(node.type) &&
364-
node.type.getText().includes('ServerRoute'),
365-
) as ts.VariableDeclaration | undefined;
366-
367-
if (!serverRoutesNode) {
323+
let recorder = host.beginUpdate(configFilePath);
324+
const configSourceFile = getSourceFile(host, configFilePath);
325+
const functionCall = findNodes(
326+
configSourceFile,
327+
ts.isCallExpression,
328+
/** max */ undefined,
329+
/** recursive */ true,
330+
).find(
331+
(n) => ts.isIdentifier(n.expression) && n.expression.getText() === 'provideServerRouting',
332+
);
333+
334+
if (!functionCall) {
368335
throw new SchematicsException(
369-
`Cannot find the "ServerRoute" configuration in "${configFilePath}".`,
336+
`Cannot find the "provideServerRouting" function call in "${configFilePath}".`,
370337
);
371338
}
372-
const recorder = host.beginUpdate(configFilePath);
373-
const arrayLiteral = serverRoutesNode.initializer as ts.ArrayLiteralExpression;
374-
const firstElementPosition =
375-
arrayLiteral.elements[0]?.getStart() ?? arrayLiteral.getStart() + 1;
376-
const newRouteString = `{
377-
path: '${APP_SHELL_ROUTE}',
378-
renderMode: RenderMode.AppShell
379-
},\n`;
380-
recorder.insertLeft(firstElementPosition, newRouteString);
339+
340+
recorder = host.beginUpdate(configFilePath);
341+
recorder.insertLeft(functionCall.end - 1, `, withAppShell(AppShellComponent)`);
342+
343+
applyToUpdateRecorder(recorder, [
344+
insertImport(configSourceFile, configFilePath, 'withAppShell', '@angular/ssr'),
345+
insertImport(
346+
configSourceFile,
347+
configFilePath,
348+
'AppShellComponent',
349+
'./app-shell/app-shell.component',
350+
),
351+
]);
381352

382353
host.commitUpdate(recorder);
383354
};
@@ -391,10 +362,14 @@ export default function (options: AppShellOptions): Rule {
391362
return chain([
392363
validateProject(browserEntryPoint),
393364
schematic('server', options),
394-
...(isStandalone
395-
? [addStandaloneServerRoute(options)]
396-
: [addRouterModule(browserEntryPoint), addServerRoutes(options)]),
397-
options.serverRouting ? noop() : addAppShellConfigToWorkspace(options),
365+
...(options.serverRouting
366+
? [noop()]
367+
: isStandalone
368+
? [addStandaloneServerRoute(options)]
369+
: [addServerRoutes(options)]),
370+
options.serverRouting
371+
? addServerRoutingConfig(options, isStandalone)
372+
: addAppShellConfigToWorkspace(options),
398373
schematic('component', {
399374
name: 'app-shell',
400375
module: 'app.module.server.ts',

‎packages/schematics/angular/app-shell/index_spec.ts

+2-99
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ describe('App Shell Schematic', () => {
6969
expect(tree.exists(filePath)).toEqual(true);
7070
});
7171

72-
it('should add router module to client app module', async () => {
73-
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
74-
const filePath = '/projects/bar/src/app/app.module.ts';
75-
const content = tree.readContent(filePath);
76-
expect(content).toMatch(/import { RouterModule } from '@angular\/router';/);
77-
});
78-
7972
it('should not fail when AppModule have imported RouterModule already', async () => {
8073
const updateRecorder = appTree.beginUpdate('/projects/bar/src/app/app.module.ts');
8174
updateRecorder.insertLeft(0, "import { RouterModule } from '@angular/router';");
@@ -87,81 +80,12 @@ describe('App Shell Schematic', () => {
8780
expect(content).toMatch(/import { RouterModule } from '@angular\/router';/);
8881
});
8982

90-
describe('Add router-outlet', () => {
91-
function makeInlineTemplate(tree: UnitTestTree, template?: string): void {
92-
template =
93-
template ||
94-
`
95-
<p>
96-
App works!
97-
</p>`;
98-
const newText = `
99-
import { Component } from '@angular/core';
100-
101-
@Component({
102-
selector: ''
103-
template: \`
104-
${template}
105-
\`,
106-
styleUrls: ['./app.component.css']
107-
})
108-
export class AppComponent { }
109-
110-
`;
111-
tree.overwrite('/projects/bar/src/app/app.component.ts', newText);
112-
tree.delete('/projects/bar/src/app/app.component.html');
113-
}
114-
115-
it('should not re-add the router outlet (external template)', async () => {
116-
const htmlPath = '/projects/bar/src/app/app.component.html';
117-
appTree.overwrite(htmlPath, '<router-outlet></router-outlet>');
118-
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
119-
const content = tree.readContent(htmlPath);
120-
const matches = content.match(/<router-outlet><\/router-outlet>/g);
121-
const numMatches = matches ? matches.length : 0;
122-
expect(numMatches).toEqual(1);
123-
});
124-
125-
it('should not re-add the router outlet (inline template)', async () => {
126-
makeInlineTemplate(appTree, '<router-outlet></router-outlet>');
127-
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
128-
const content = tree.readContent('/projects/bar/src/app/app.component.ts');
129-
const matches = content.match(/<router-outlet><\/router-outlet>/g);
130-
const numMatches = matches ? matches.length : 0;
131-
expect(numMatches).toEqual(1);
132-
});
133-
});
134-
135-
it('should add router imports to server module', async () => {
136-
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
137-
const filePath = '/projects/bar/src/app/app.module.server.ts';
138-
const content = tree.readContent(filePath);
139-
expect(content).toMatch(/import { Routes, RouterModule } from '@angular\/router';/);
140-
});
141-
14283
it('should work if server config was added prior to running the app-shell schematic', async () => {
14384
let tree = await schematicRunner.runSchematic('server', defaultOptions, appTree);
14485
tree = await schematicRunner.runSchematic('app-shell', defaultOptions, tree);
14586
expect(tree.exists('/projects/bar/src/app/app-shell/app-shell.component.ts')).toBe(true);
14687
});
14788

148-
it('should define a server route', async () => {
149-
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
150-
const filePath = '/projects/bar/src/app/app.module.server.ts';
151-
const content = tree.readContent(filePath);
152-
expect(content).toMatch(/const routes: Routes = \[/);
153-
});
154-
155-
it('should import RouterModule with forRoot', async () => {
156-
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
157-
const filePath = '/projects/bar/src/app/app.module.server.ts';
158-
const content = tree.readContent(filePath);
159-
expect(content).toMatch(
160-
/const routes: Routes = \[ { path: 'shell', component: AppShellComponent }\];/,
161-
);
162-
expect(content).toContain(`ServerModule, RouterModule.forRoot(routes)]`);
163-
});
164-
16589
it('should create the shell component', async () => {
16690
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
16791
expect(tree.exists('/projects/bar/src/app/app-shell/app-shell.component.ts')).toBe(true);
@@ -200,35 +124,14 @@ describe('App Shell Schematic', () => {
200124
expect(content).toMatch(/app-shell\.component/);
201125
});
202126

203-
it(`should update the 'provideServerRoutesConfig' call to include 'appShellRoute`, async () => {
127+
it(`should update the 'provideServerRouting' call to include 'withAppShell'`, async () => {
204128
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
205129
const content = tree.readContent('/projects/bar/src/app/app.config.server.ts');
206130
expect(tags.oneLine`${content}`).toContain(
207-
tags.oneLine`provideServerRoutesConfig(serverRoutes, { appShellRoute: 'shell' })`,
131+
tags.oneLine`provideServerRouting(serverRoutes, withAppShell(AppShellComponent))`,
208132
);
209133
});
210134

211-
it('should define a server route', async () => {
212-
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
213-
const filePath = '/projects/bar/src/app/app.config.server.ts';
214-
const content = tree.readContent(filePath);
215-
expect(tags.oneLine`${content}`).toContain(tags.oneLine`{
216-
provide: ROUTES,
217-
multi: true,
218-
useValue: [{
219-
path: 'shell',
220-
component: AppShellComponent
221-
}]
222-
}`);
223-
});
224-
225-
it(`should add import to 'ROUTES' token from '@angular/router'`, async () => {
226-
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
227-
const filePath = '/projects/bar/src/app/app.config.server.ts';
228-
const content = tree.readContent(filePath);
229-
expect(content).toContain(`import { ROUTES } from '@angular/router';`);
230-
});
231-
232135
it(`should add import to 'AppShellComponent'`, async () => {
233136
const tree = await schematicRunner.runSchematic('app-shell', defaultOptions, appTree);
234137
const filePath = '/projects/bar/src/app/app.config.server.ts';
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { NgModule } from '@angular/core';
22
import { ServerModule } from '@angular/platform-server';<% if(serverRouting) { %>
3-
import { provideServerRoutesConfig } from '@angular/ssr';<% } %>
3+
import { provideServerRouting } from '@angular/ssr';<% } %>
44
import { AppComponent } from './app.component';
55
import { AppModule } from './app.module';<% if(serverRouting) { %>
66
import { serverRoutes } from './app.routes.server';<% } %>
77

88
@NgModule({
99
imports: [AppModule, ServerModule],<% if(serverRouting) { %>
10-
providers: [provideServerRoutesConfig(serverRoutes)],<% } %>
10+
providers: [provideServerRouting(serverRoutes)],<% } %>
1111
bootstrap: [AppComponent],
1212
})
1313
export class AppServerModule {}

‎packages/schematics/angular/server/files/application-builder/standalone-src/app/app.config.server.ts.template

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
22
import { provideServerRendering } from '@angular/platform-server';<% if(serverRouting) { %>
3-
import { provideServerRoutesConfig } from '@angular/ssr';<% } %>
3+
import { provideServerRouting } from '@angular/ssr';<% } %>
44
import { appConfig } from './app.config';<% if(serverRouting) { %>
55
import { serverRoutes } from './app.routes.server';<% } %>
66

77
const serverConfig: ApplicationConfig = {
88
providers: [
99
provideServerRendering(),<% if(serverRouting) { %>
10-
provideServerRoutesConfig(serverRoutes)<% } %>
10+
provideServerRouting(serverRoutes)<% } %>
1111
]
1212
};
1313

0 commit comments

Comments
 (0)
Please sign in to comment.