Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/angular/ssr/src/routes/ng-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ export async function getRoutesFromAngularRouterConfig(
const moduleRef = await platformRef.bootstrapModule(bootstrap);
applicationRef = moduleRef.injector.get(ApplicationRef);
} else {
applicationRef = await bootstrap();
applicationRef = await bootstrap(platformRef.injector);
}

const injector = applicationRef.injector;
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/ssr/src/routes/route-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,16 @@ export function withAppShell(
*
* @example
* Basic example of how you can enable server-side rendering in your application
* when using the `bootstrapApplication` function:
* when using the `bootstrapServerApplication` function:
*
* ```ts
* import { bootstrapApplication } from '@angular/platform-browser';
* import { bootstrapServerApplication } from '@angular/platform-server';
* import { provideServerRendering, withRoutes, withAppShell } from '@angular/ssr';
* import { AppComponent } from './app/app.component';
* import { SERVER_ROUTES } from './app/app.server.routes';
* import { AppShellComponent } from './app/app-shell.component';
*
* bootstrapApplication(AppComponent, {
* export default bootstrapServerApplication(AppComponent, {
* providers: [
* provideServerRendering(
* withRoutes(SERVER_ROUTES),
Expand Down
5 changes: 3 additions & 2 deletions packages/angular/ssr/src/utils/ng.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import {
INITIAL_CONFIG,
ɵSERVER_CONTEXT as SERVER_CONTEXT,
bootstrapServerApplication,
platformServer,
ɵrenderInternal as renderInternal,
} from '@angular/platform-server';
Expand All @@ -31,7 +32,7 @@ import { joinUrlParts, stripIndexHtmlFromURL } from './url';
* - A reference to an Angular component or module (`Type<unknown>`) that serves as the root of the application.
* - A function that returns a `Promise<ApplicationRef>`, which resolves with the root application reference.
*/
export type AngularBootstrap = Type<unknown> | (() => Promise<ApplicationRef>);
export type AngularBootstrap = Type<unknown> | ReturnType<typeof bootstrapServerApplication>;

/**
* Renders an Angular application or module to an HTML string.
Expand Down Expand Up @@ -90,7 +91,7 @@ export async function renderAngular(
const moduleRef = await platformRef.bootstrapModule(bootstrap);
applicationRef = moduleRef.injector.get(ApplicationRef);
} else {
applicationRef = await bootstrap();
applicationRef = await bootstrap(platformRef.injector);
}

// Block until application is stable.
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/ssr/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ts_project(
"//:node_modules/@angular/common",
"//:node_modules/@angular/compiler",
"//:node_modules/@angular/core",
"//:node_modules/@angular/platform-browser",
"//:node_modules/@angular/platform-server",
"//:node_modules/@angular/router",
"//:node_modules/@types/node",
"//packages/angular/ssr",
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/ssr/test/testing-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Type,
provideZonelessChangeDetection,
} from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { bootstrapServerApplication } from '@angular/platform-server';
import { RouterOutlet, Routes, provideRouter } from '@angular/router';
import { destroyAngularServerApp } from '../src/app';
import { ServerAsset, setAngularAppManifest } from '../src/manifest';
Expand Down Expand Up @@ -90,8 +90,8 @@ export function setAngularAppTestingManifest(
`,
},
},
bootstrap: async () => () => {
return bootstrapApplication(rootComponent, {
bootstrap: async () => {
return bootstrapServerApplication(rootComponent, {
providers: [
provideZonelessChangeDetection(),
provideRouter(routes),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { bootstrapServerApplication } from '@angular/platform-server';
import { <%= appComponentName %> } from '<%= appComponentPath %>';
import { config } from './app/app.config.server';

const bootstrap = () => bootstrapApplication(<%= appComponentName %>, config);

export default bootstrap;
export default bootstrapServerApplication(<%= appComponentName %>, config);
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { bootstrapServerApplication } from '@angular/platform-server';
import { <%= appComponentName %> } from '<%= appComponentPath %>';
import { config } from './app/app.config.server';

const bootstrap = () => bootstrapApplication(<%= appComponentName %>, config);

export default bootstrap;
export default bootstrapServerApplication(<%= appComponentName %>, config);
14 changes: 7 additions & 7 deletions packages/schematics/angular/utility/standalone/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@ export function getSourceFile(tree: Tree, path: string): ts.SourceFile {
return source;
}

/** Finds the call to `bootstrapApplication` within a file. */
/** Finds the call to `bootstrapApplication` or `bootstrapServerApplication` within a file. */
export function findBootstrapApplicationCall(tree: Tree, mainFilePath: string): ts.CallExpression {
const sourceFile = getSourceFile(tree, mainFilePath);
const localName = findImportLocalName(
sourceFile,
'bootstrapApplication',
'@angular/platform-browser',
);
const localName =
findImportLocalName(sourceFile, 'bootstrapApplication', '@angular/platform-browser') ??
findImportLocalName(sourceFile, 'bootstrapServerApplication', '@angular/platform-server');

if (localName) {
let result: ts.CallExpression | null = null;
Expand All @@ -86,7 +84,9 @@ export function findBootstrapApplicationCall(tree: Tree, mainFilePath: string):
}
}

throw new SchematicsException(`Could not find bootstrapApplication call in ${mainFilePath}`);
throw new SchematicsException(
`Could not find bootstrapApplication or bootstrapServerApplication call in ${mainFilePath}`,
);
}

/**
Expand Down
Loading