Skip to content

Commit

Permalink
fix(@angular/ssr): disable component bootstrapping during route extra…
Browse files Browse the repository at this point in the history
…ction

This commit disables component bootstrapping during route extraction to prevent invoking the AppComponent and its lifecycle hooks.

Closes angular#29085
  • Loading branch information
alan-agius4 committed Dec 10, 2024
1 parent 451a4c6 commit 91ff536
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/angular/ssr/src/routes/ng-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
*/

import { APP_BASE_HREF, PlatformLocation } from '@angular/common';
import { ApplicationRef, Compiler, Injector, runInInjectionContext, ɵConsole } from '@angular/core';
import {
ApplicationRef,
Compiler,
Injector,
runInInjectionContext,
ɵConsole,
ɵDISABLE_COMPONENT_BOOTSTRAP,
} from '@angular/core';
import { INITIAL_CONFIG, platformServer } from '@angular/platform-server';
import {
Route as AngularRoute,
Expand Down Expand Up @@ -479,6 +486,10 @@ export async function getRoutesFromAngularRouterConfig(
provide: ɵConsole,
useFactory: () => new Console(),
},
{
provide: ɵDISABLE_COMPONENT_BOOTSTRAP,
useValue: true,
},
]);

try {
Expand Down

0 comments on commit 91ff536

Please sign in to comment.