Skip to content
Merged
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
4 changes: 2 additions & 2 deletions constants.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ RELEASE_ENGINES_NODE = "^20.19.0 || ^22.12.0 || >=24.0.0"
RELEASE_ENGINES_NPM = "^6.11.0 || ^7.5.6 || >=8.0.0"
RELEASE_ENGINES_YARN = ">= 1.13.0"

NG_PACKAGR_VERSION = "^20.2.0"
ANGULAR_FW_VERSION = "^20.2.0"
NG_PACKAGR_VERSION = "^20.3.0"
ANGULAR_FW_VERSION = "^20.3.0"
ANGULAR_FW_PEER_DEP = "^20.0.0"
NG_PACKAGR_PEER_DEP = "^20.0.0"

Expand Down
5 changes: 3 additions & 2 deletions goldens/public-api/angular/ssr/node/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
```ts

import { ApplicationRef } from '@angular/core';
import { BootstrapContext } from '@angular/platform-browser';
import { Http2ServerRequest } from 'node:http2';
import { Http2ServerResponse } from 'node:http2';
import { IncomingMessage } from 'node:http';
Expand All @@ -26,14 +27,14 @@ export class CommonEngine {

// @public (undocumented)
export interface CommonEngineOptions {
bootstrap?: Type<{}> | (() => Promise<ApplicationRef>);
bootstrap?: Type<{}> | ((context: BootstrapContext) => Promise<ApplicationRef>);
enablePerformanceProfiler?: boolean;
providers?: StaticProvider[];
}

// @public (undocumented)
export interface CommonEngineRenderOptions {
bootstrap?: Type<{}> | (() => Promise<ApplicationRef>);
bootstrap?: Type<{}> | ((context: BootstrapContext) => Promise<ApplicationRef>);
// (undocumented)
document?: string;
// (undocumented)
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@
},
"homepage": "https://github.com/angular/angular-cli",
"devDependencies": {
"@angular/animations": "20.2.4",
"@angular/animations": "20.3.0",
"@angular/cdk": "20.2.2",
"@angular/common": "20.2.4",
"@angular/compiler": "20.2.4",
"@angular/compiler-cli": "20.2.4",
"@angular/core": "20.2.4",
"@angular/forms": "20.2.4",
"@angular/localize": "20.2.4",
"@angular/common": "20.3.0",
"@angular/compiler": "20.3.0",
"@angular/compiler-cli": "20.3.0",
"@angular/core": "20.3.0",
"@angular/forms": "20.3.0",
"@angular/localize": "20.3.0",
"@angular/material": "20.2.2",
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#1b75cbad43a688705205725df89bf311a8d08652",
"@angular/platform-browser": "20.2.4",
"@angular/platform-server": "20.2.4",
"@angular/router": "20.2.4",
"@angular/service-worker": "20.2.4",
"@angular/platform-browser": "20.3.0",
"@angular/platform-server": "20.3.0",
"@angular/router": "20.3.0",
"@angular/service-worker": "20.3.0",
"@bazel/bazelisk": "1.26.0",
"@bazel/buildifier": "8.2.1",
"@eslint/compat": "1.3.2",
Expand Down
1 change: 1 addition & 0 deletions packages/angular/build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ ts_project(
"//:node_modules/@angular/compiler-cli",
"//:node_modules/@angular/core",
"//:node_modules/@angular/localize",
"//:node_modules/@angular/platform-browser",
"//:node_modules/@angular/platform-server",
"//:node_modules/@angular/service-worker",
"//:node_modules/@types/babel__core",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@angular-devkit/core": "workspace:*",
"jsdom": "26.1.0",
"less": "4.4.0",
"ng-packagr": "20.2.0",
"ng-packagr": "20.3.0",
"postcss": "8.5.6",
"rxjs": "7.8.2",
"vitest": "3.2.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import type { ApplicationRef, Type } from '@angular/core';
import type { BootstrapContext } from '@angular/platform-browser';
import type { ɵextractRoutesAndCreateRouteTree, ɵgetOrCreateAngularServerApp } from '@angular/ssr';
import { assertIsError } from '../error';
import { loadEsmModule } from '../load-esm';
Expand All @@ -15,7 +16,7 @@ import { loadEsmModule } from '../load-esm';
* Represents the exports available from the main server bundle.
*/
interface MainServerBundleExports {
default: (() => Promise<ApplicationRef>) | Type<unknown>;
default: ((context: BootstrapContext) => Promise<ApplicationRef>) | Type<unknown>;
ɵextractRoutesAndCreateRouteTree: typeof ɵextractRoutesAndCreateRouteTree;
ɵgetOrCreateAngularServerApp: typeof ɵgetOrCreateAngularServerApp;
}
Expand Down
1 change: 1 addition & 0 deletions packages/angular/ssr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ts_project(
deps = [
"//:node_modules/@angular/common",
"//:node_modules/@angular/core",
"//:node_modules/@angular/platform-browser",
"//:node_modules/@angular/platform-server",
"//:node_modules/@angular/router",
"//:node_modules/tslib",
Expand Down
9 changes: 6 additions & 3 deletions packages/angular/ssr/node/src/common-engine/common-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { ApplicationRef, StaticProvider, Type } from '@angular/core';
import { BootstrapContext } from '@angular/platform-browser';
import { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';
import * as fs from 'node:fs';
import { dirname, join, normalize, resolve } from 'node:path';
Expand All @@ -23,7 +24,7 @@ const SSG_MARKER_REGEXP = /ng-server-context=["']\w*\|?ssg\|?\w*["']/;

export interface CommonEngineOptions {
/** A method that when invoked returns a promise that returns an `ApplicationRef` instance once resolved or an NgModule. */
bootstrap?: Type<{}> | (() => Promise<ApplicationRef>);
bootstrap?: Type<{}> | ((context: BootstrapContext) => Promise<ApplicationRef>);

/** A set of platform level providers for all requests. */
providers?: StaticProvider[];
Expand All @@ -34,7 +35,7 @@ export interface CommonEngineOptions {

export interface CommonEngineRenderOptions {
/** A method that when invoked returns a promise that returns an `ApplicationRef` instance once resolved or an NgModule. */
bootstrap?: Type<{}> | (() => Promise<ApplicationRef>);
bootstrap?: Type<{}> | ((context: BootstrapContext) => Promise<ApplicationRef>);

/** A set of platform level providers for the current request. */
providers?: StaticProvider[];
Expand Down Expand Up @@ -197,7 +198,9 @@ async function exists(path: fs.PathLike): Promise<boolean> {
}
}

function isBootstrapFn(value: unknown): value is () => Promise<ApplicationRef> {
function isBootstrapFn(
value: unknown,
): value is (context: BootstrapContext) => Promise<ApplicationRef> {
// We can differentiate between a module and a bootstrap function by reading compiler-generated `ɵmod` static property:
return typeof value === 'function' && !('ɵmod' in value);
}
12 changes: 6 additions & 6 deletions packages/angular/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
},
"devDependencies": {
"@angular-devkit/schematics": "workspace:*",
"@angular/common": "20.2.4",
"@angular/compiler": "20.2.4",
"@angular/core": "20.2.4",
"@angular/platform-browser": "20.2.4",
"@angular/platform-server": "20.2.4",
"@angular/router": "20.2.4",
"@angular/common": "20.3.0",
"@angular/compiler": "20.3.0",
"@angular/core": "20.3.0",
"@angular/platform-browser": "20.3.0",
"@angular/platform-server": "20.3.0",
"@angular/router": "20.3.0",
"@schematics/angular": "workspace:*"
},
"sideEffects": false,
Expand Down
1 change: 1 addition & 0 deletions packages/angular/ssr/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import type { BootstrapContext } from '@angular/platform-browser';
import type { SerializableRouteTreeNode } from './routes/route-tree';
import { AngularBootstrap } from './utils/ng';

Expand Down
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 });
}

const injector = applicationRef.injector;
Expand Down
21 changes: 12 additions & 9 deletions packages/angular/ssr/src/routes/route-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,20 +356,23 @@ export function withAppShell(
* when using the `bootstrapApplication` function:
*
* ```ts
* import { bootstrapApplication } from '@angular/platform-browser';
* import { bootstrapApplication, BootstrapContext } from '@angular/platform-browser';
* 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, {
* providers: [
* provideServerRendering(
* withRoutes(SERVER_ROUTES),
* withAppShell(AppShellComponent)
* )
* ]
* });
* const bootstrap = (context: BootstrapContext) =>
* bootstrapApplication(AppComponent, {
* providers: [
* provideServerRendering(
* withRoutes(SERVER_ROUTES),
* withAppShell(AppShellComponent),
* ),
* ],
* }, context);
*
* export default bootstrap;
* ```
* @see {@link withRoutes} configures server-side routing
* @see {@link withAppShell} configures the application shell
Expand Down
7 changes: 5 additions & 2 deletions packages/angular/ssr/src/utils/ng.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
type Type,
ɵConsole,
} from '@angular/core';
import { BootstrapContext } from '@angular/platform-browser';
import {
INITIAL_CONFIG,
ɵSERVER_CONTEXT as SERVER_CONTEXT,
Expand All @@ -31,7 +32,9 @@ 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>
| ((context: BootstrapContext) => Promise<ApplicationRef>);

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

// Block until application is stable.
Expand Down
22 changes: 13 additions & 9 deletions packages/angular/ssr/test/testing-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,19 @@ export function setAngularAppTestingManifest(
`,
},
},
bootstrap: async () => () => {
return bootstrapApplication(rootComponent, {
providers: [
provideZonelessChangeDetection(),
provideRouter(routes),
provideServerRendering(withRoutes(serverRoutes)),
...extraProviders,
],
});
bootstrap: async () => (context) => {
return bootstrapApplication(
rootComponent,
{
providers: [
provideZonelessChangeDetection(),
provideRouter(routes),
provideServerRendering(withRoutes(serverRoutes)),
...extraProviders,
],
},
context,
);
},
});
}
1 change: 1 addition & 0 deletions packages/angular_devkit/build_angular/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ ts_project(
"//:node_modules/@angular/compiler-cli",
"//:node_modules/@angular/core",
"//:node_modules/@angular/localize",
"//:node_modules/@angular/platform-browser",
"//:node_modules/@angular/platform-server",
"//:node_modules/@angular/service-worker",
"//:node_modules/@types/babel__core",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/build_angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@angular/ssr": "workspace:*",
"@web/test-runner": "0.20.2",
"browser-sync": "3.0.4",
"ng-packagr": "20.2.0",
"ng-packagr": "20.3.0",
"undici": "7.13.0"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import type { ApplicationRef, StaticProvider, Type } from '@angular/core';
import type { BootstrapContext } from '@angular/platform-browser';
import type { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';
import assert from 'node:assert';
import { workerData } from 'node:worker_threads';
Expand All @@ -33,7 +34,7 @@ interface ServerBundleExports {
renderApplication?: typeof renderApplication;

/** Standalone application bootstrapping function. */
default?: () => Promise<ApplicationRef>;
default?: (context: BootstrapContext) => Promise<ApplicationRef>;
}

/**
Expand Down Expand Up @@ -121,7 +122,9 @@ async function render({ serverBundlePath, document, url }: RenderRequest): Promi
return Promise.race([renderAppPromise, renderingTimeout]).finally(() => clearTimeout(timer));
}

function isBootstrapFn(value: unknown): value is () => Promise<ApplicationRef> {
function isBootstrapFn(
value: unknown,
): value is (context: BootstrapContext) => Promise<ApplicationRef> {
// We can differentiate between a module and a bootstrap function by reading compiler-generated `ɵmod` static property:
return typeof value === 'function' && !('ɵmod' in value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import type { ApplicationRef, StaticProvider, Type } from '@angular/core';
import type { BootstrapContext } from '@angular/platform-browser';
import type { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';
import assert from 'node:assert';
import * as fs from 'node:fs';
Expand Down Expand Up @@ -42,7 +43,7 @@ interface ServerBundleExports {
renderApplication?: typeof renderApplication;

/** Standalone application bootstrapping function. */
default?: (() => Promise<ApplicationRef>) | Type<unknown>;
default?: ((context: BootstrapContext) => Promise<ApplicationRef>) | Type<unknown>;
}

/**
Expand Down Expand Up @@ -148,7 +149,9 @@ async function render({
return result;
}

function isBootstrapFn(value: unknown): value is () => Promise<ApplicationRef> {
function isBootstrapFn(
value: unknown,
): value is (context: BootstrapContext) => Promise<ApplicationRef> {
// We can differentiate between a module and a bootstrap function by reading compiler-generated `ɵmod` static property:
return typeof value === 'function' && !('ɵmod' in value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import type { ApplicationRef, Type } from '@angular/core';
import type { BootstrapContext } from '@angular/platform-browser';
import type { ɵgetRoutesFromAngularRouterConfig } from '@angular/ssr';
import assert from 'node:assert';
import * as fs from 'node:fs';
Expand All @@ -25,7 +26,7 @@ interface ServerBundleExports {
AppServerModule?: Type<unknown>;

/** Standalone application bootstrapping function. */
default?: (() => Promise<ApplicationRef>) | Type<unknown>;
default?: ((context: BootstrapContext) => Promise<ApplicationRef>) | Type<unknown>;

/** Method to extract routes from the router config. */
ɵgetRoutesFromAngularRouterConfig: typeof ɵgetRoutesFromAngularRouterConfig;
Expand Down
4 changes: 2 additions & 2 deletions packages/ngtools/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
},
"devDependencies": {
"@angular-devkit/core": "workspace:0.0.0-PLACEHOLDER",
"@angular/compiler": "20.2.4",
"@angular/compiler-cli": "20.2.4",
"@angular/compiler": "20.3.0",
"@angular/compiler-cli": "20.3.0",
"typescript": "5.9.2",
"webpack": "5.101.2"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { BootstrapContext, bootstrapApplication } from '@angular/platform-browser';
import { <%= appComponentName %> } from '<%= appComponentPath %>';
import { config } from './app/app.config.server';

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

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

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

export default bootstrap;
Loading