Skip to content

Commit 776f0cb

Browse files
committed
fix(@angular/ssr): disable component bootstrapping during route extraction
This commit disables component bootstrapping during route extraction to prevent invoking the AppComponent and its lifecycle hooks. Closes #29085
1 parent 41ece63 commit 776f0cb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/angular/ssr/src/routes/ng-routes.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
*/
88

99
import { APP_BASE_HREF, PlatformLocation } from '@angular/common';
10-
import { ApplicationRef, Compiler, Injector, runInInjectionContext, ɵConsole } from '@angular/core';
10+
import {
11+
ApplicationRef,
12+
Compiler,
13+
Injector,
14+
runInInjectionContext,
15+
ɵConsole,
16+
ɵDISABLE_COMPONENT_BOOTSTRAP,
17+
} from '@angular/core';
1118
import { INITIAL_CONFIG, platformServer } from '@angular/platform-server';
1219
import {
1320
Route as AngularRoute,
@@ -479,6 +486,10 @@ export async function getRoutesFromAngularRouterConfig(
479486
provide: ɵConsole,
480487
useFactory: () => new Console(),
481488
},
489+
{
490+
provide: ɵDISABLE_COMPONENT_BOOTSTRAP,
491+
useValue: true,
492+
},
482493
]);
483494

484495
try {

0 commit comments

Comments
 (0)