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
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 @@ -25,14 +26,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
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@
"homepage": "https://github.com/angular/angular-cli",
"devDependencies": {
"@ampproject/remapping": "2.3.0",
"@angular/animations": "19.2.0-rc.0",
"@angular/animations": "19.2.15",
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#d4727212a9d0f7eb63ae3116d73c769d9bd0bdc1",
"@angular/cdk": "19.2.0-rc.0",
"@angular/common": "19.2.0-rc.0",
"@angular/compiler": "19.2.0-rc.0",
"@angular/compiler-cli": "19.2.0-rc.0",
"@angular/core": "19.2.0-rc.0",
"@angular/forms": "19.2.0-rc.0",
"@angular/localize": "19.2.0-rc.0",
"@angular/common": "19.2.15",
"@angular/compiler": "19.2.15",
"@angular/compiler-cli": "19.2.15",
"@angular/core": "19.2.15",
"@angular/forms": "19.2.15",
"@angular/localize": "19.2.15",
"@angular/material": "19.2.0-rc.0",
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#252589f7bc8fe6ca13b31e02d506ec52e826cdd2",
"@angular/platform-browser": "19.2.0-rc.0",
"@angular/platform-browser-dynamic": "19.2.0-rc.0",
"@angular/platform-server": "19.2.0-rc.0",
"@angular/router": "19.2.0-rc.0",
"@angular/service-worker": "19.2.0-rc.0",
"@angular/platform-browser": "19.2.15",
"@angular/platform-browser-dynamic": "19.2.15",
"@angular/platform-server": "19.2.15",
"@angular/router": "19.2.15",
"@angular/service-worker": "19.2.15",
"@babel/core": "7.26.10",
"@babel/generator": "7.26.10",
"@babel/helper-annotate-as-pure": "7.25.9",
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 @@ -87,6 +87,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/@babel/core",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ export async function* serveWithVite(
browserOptions.loader as EsbuildLoaderOption | undefined,
{
...browserOptions.define,
'ngJitMode': browserOptions.aot ? 'false' : 'true',
'ngHmrMode': browserOptions.templateUpdates ? 'true' : 'false',
},
extensions?.middleware,
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 @@ -22,7 +23,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 @@ -33,7 +34,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 @@ -194,7 +195,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": "19.2.0-rc.0",
"@angular/compiler": "19.2.0-rc.0",
"@angular/core": "19.2.0-rc.0",
"@angular/platform-browser": "19.2.0-rc.0",
"@angular/platform-server": "19.2.0-rc.0",
"@angular/router": "19.2.0-rc.0",
"@angular/common": "19.2.15",
"@angular/compiler": "19.2.15",
"@angular/core": "19.2.15",
"@angular/platform-browser": "19.2.15",
"@angular/platform-server": "19.2.15",
"@angular/router": "19.2.15",
"@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 @@ -629,7 +629,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
5 changes: 4 additions & 1 deletion packages/angular/ssr/src/utils/ng.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { ɵConsole } from '@angular/core';
import type { ApplicationRef, StaticProvider, Type } from '@angular/core';
import { BootstrapContext } from '@angular/platform-browser';
import {
ɵSERVER_CONTEXT as SERVER_CONTEXT,
renderApplication,
Expand All @@ -23,7 +24,9 @@ import { 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
24 changes: 14 additions & 10 deletions packages/angular/ssr/test/testing-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,20 @@ export function setAngularAppTestingManifest(
`,
},
},
bootstrap: async () => () => {
return bootstrapApplication(rootComponent, {
providers: [
provideServerRendering(),
provideExperimentalZonelessChangeDetection(),
provideRouter(routes),
provideServerRouting(serverRoutes),
...extraProviders,
],
});
bootstrap: async () => (context) => {
return bootstrapApplication(
rootComponent,
{
providers: [
provideServerRendering(),
provideExperimentalZonelessChangeDetection(),
provideRouter(routes),
provideServerRouting(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 @@ -142,6 +142,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/@babel/core",
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
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ async function initialize(
{
plugins: [
new webpack.DefinePlugin({
'ngJitMode': false,
'ngServerMode': true,
}),
],
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": "19.2.0-rc.0",
"@angular/compiler-cli": "19.2.0-rc.0",
"@angular/compiler": "19.2.15",
"@angular/compiler-cli": "19.2.15",
"typescript": "5.8.1-rc",
"webpack": "5.98.0"
}
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 { AppComponent } from './app/app.component';
import { config } from './app/app.config.server';

const bootstrap = () => bootstrapApplication(AppComponent, config);
const bootstrap = (context: BootstrapContext) =>
bootstrapApplication(AppComponent, 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 { AppComponent } from './app/app.component';
import { config } from './app/app.config.server';

const bootstrap = () => bootstrapApplication(AppComponent, config);
const bootstrap = (context: BootstrapContext) =>
bootstrapApplication(AppComponent, config, context);

export default bootstrap;
2 changes: 1 addition & 1 deletion packages/schematics/angular/server/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('Server Schematic', () => {
const filePath = '/projects/bar/src/main.server.ts';
expect(tree.exists(filePath)).toBeTrue();
const contents = tree.readContent(filePath);
expect(contents).toContain(`bootstrapApplication(AppComponent, config)`);
expect(contents).toContain(`bootstrapApplication(AppComponent, config, context)`);
});

it('should create server app config file', async () => {
Expand Down
Loading
Loading