@@ -45,7 +45,7 @@ const VALID_REDIRECT_RESPONSE_CODES = new Set([301, 302, 303, 307, 308]);
45
45
*/
46
46
type ServerConfigRouteTreeAdditionalMetadata = Partial < ServerRoute > & {
47
47
/** Indicates if the route has been matched with the Angular router routes. */
48
- matched ?: boolean ;
48
+ presentInClientRouter ?: boolean ;
49
49
} ;
50
50
51
51
/**
@@ -134,15 +134,15 @@ async function* traverseRoutesConfig(options: {
134
134
continue ;
135
135
}
136
136
137
- matchedMetaData . matched = true ;
137
+ matchedMetaData . presentInClientRouter = true ;
138
138
}
139
139
140
140
const metadata : ServerConfigRouteTreeNodeMetadata = {
141
141
...matchedMetaData ,
142
142
route : currentRoutePath ,
143
143
} ;
144
144
145
- delete metadata . matched ;
145
+ delete metadata . presentInClientRouter ;
146
146
147
147
// Handle redirects
148
148
if ( typeof redirectTo === 'string' ) {
@@ -246,8 +246,8 @@ async function* handleSSGRoute(
246
246
if ( ! getPrerenderParams ) {
247
247
yield {
248
248
error :
249
- `The '${ stripLeadingSlash ( currentRoutePath ) } ' route uses prerendering and includes parameters, but 'getPrerenderParams' is missing. ` +
250
- `Please define 'getPrerenderParams' function for this route in your server routing configuration ` +
249
+ `The '${ stripLeadingSlash ( currentRoutePath ) } ' route uses prerendering and includes parameters, but 'getPrerenderParams' ` +
250
+ `is missing. Please define 'getPrerenderParams' function for this route in your server routing configuration ` +
251
251
`or specify a different 'renderMode'.` ,
252
252
} ;
253
253
@@ -442,24 +442,38 @@ export async function getRoutesFromAngularRouterConfig(
442
442
includePrerenderFallbackRoutes,
443
443
} ) ;
444
444
445
+ let seenAppShellRoute : string | undefined ;
445
446
for await ( const result of traverseRoutes ) {
446
447
if ( 'error' in result ) {
447
448
errors . push ( result . error ) ;
448
449
} else {
450
+ if ( result . renderMode === RenderMode . AppShell ) {
451
+ if ( seenAppShellRoute !== undefined ) {
452
+ errors . push (
453
+ `Error: Both '${ seenAppShellRoute } ' and '${ stripLeadingSlash ( result . route ) } ' routes have ` +
454
+ `their 'renderMode' set to 'AppShell'. AppShell renderMode should only be assigned to one route. ` +
455
+ `Please review your route configurations to ensure that only one route is set to 'RenderMode.AppShell'.` ,
456
+ ) ;
457
+ }
458
+
459
+ seenAppShellRoute = stripLeadingSlash ( result . route ) ;
460
+ }
461
+
449
462
routesResults . push ( result ) ;
450
463
}
451
464
}
452
465
453
466
if ( serverConfigRouteTree ) {
454
- for ( const { route, matched } of serverConfigRouteTree . traverse ( ) ) {
455
- if ( matched || route === '**' ) {
467
+ for ( const { route, presentInClientRouter } of serverConfigRouteTree . traverse ( ) ) {
468
+ if ( presentInClientRouter || route === '**' ) {
456
469
// Skip if matched or it's the catch-all route.
457
470
continue ;
458
471
}
459
472
460
473
errors . push (
461
- `The server route '${ route } ' does not match any routes defined in the Angular routing configuration. ` +
462
- 'Please verify and if unneeded remove this route from the server configuration.' ,
474
+ `The '${ route } ' server route does not match any routes defined in the Angular ` +
475
+ `routing configuration (typically provided as a part of the 'provideRouter' call). ` +
476
+ 'Please make sure that the mentioned server route is present in the Angular routing configuration.' ,
463
477
) ;
464
478
}
465
479
}
0 commit comments