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/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 { StaticProvider } from '@angular/core';
import { Type } from '@angular/core';

Expand All @@ -16,14 +17,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
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@
},
"devDependencies": {
"@ampproject/remapping": "2.3.0",
"@angular/animations": "18.2.0",
"@angular/animations": "18.2.14",
"@angular/bazel": "patch:@angular/bazel@https%3A//github.com/angular/bazel-builds.git%23commit=71bd2e043e076365effdb6076f33b2d8d6bd6d02#~/.yarn/patches/@angular-bazel-https-9848736cf4.patch",
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#8128c8cc982b49ca12490da8d97692143aefd026",
"@angular/cdk": "18.1.3",
"@angular/common": "18.2.0",
"@angular/compiler": "18.2.0",
"@angular/compiler-cli": "18.2.0",
"@angular/core": "18.2.0",
"@angular/forms": "18.2.0",
"@angular/localize": "18.2.0",
"@angular/common": "18.2.14",
"@angular/compiler": "18.2.14",
"@angular/compiler-cli": "18.2.14",
"@angular/core": "18.2.14",
"@angular/forms": "18.2.14",
"@angular/localize": "18.2.14",
"@angular/material": "18.1.3",
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#871fbcb75819dba4dfc6c8971c7aec1c57a8de0c",
"@angular/platform-browser": "18.2.0",
"@angular/platform-browser-dynamic": "18.2.0",
"@angular/platform-server": "18.2.0",
"@angular/router": "18.2.0",
"@angular/service-worker": "18.2.0",
"@angular/platform-browser": "18.2.14",
"@angular/platform-browser-dynamic": "18.2.14",
"@angular/platform-server": "18.2.14",
"@angular/router": "18.2.14",
"@angular/service-worker": "18.2.14",
"@babel/core": "7.26.10",
"@babel/generator": "7.26.10",
"@babel/helper-annotate-as-pure": "7.25.9",
Expand Down Expand Up @@ -164,7 +164,7 @@
"magic-string": "0.30.11",
"mini-css-extract-plugin": "2.9.0",
"mrmime": "2.0.0",
"ng-packagr": "18.2.0-next.0",
"ng-packagr": "^18.2.0",
"npm": "^10.8.1",
"npm-package-arg": "11.0.3",
"npm-pick-manifest": "9.1.0",
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 @@ -62,6 +62,7 @@ ts_library(
"@npm//@angular/compiler-cli",
"@npm//@angular/core",
"@npm//@angular/localize",
"@npm//@angular/platform-browser",
"@npm//@angular/platform-server",
"@npm//@angular/service-worker",
"@npm//@babel/core",
Expand Down
9 changes: 9 additions & 0 deletions packages/angular/build/src/builders/dev-server/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export async function* serveWithVite(
extensions?.middleware,
transformers?.indexHtml,
thirdPartySourcemaps,
!!browserOptions.aot,
);

server = await createServer(serverConfiguration);
Expand Down Expand Up @@ -503,6 +504,7 @@ export async function setupServer(
extensionMiddleware?: Connect.NextHandleFunction[],
indexHtmlTransformer?: (content: string) => Promise<string>,
thirdPartySourcemaps = false,
aot = false,
): Promise<InlineConfig> {
const proxy = await loadProxyConfiguration(
serverOptions.workspaceRoot,
Expand Down Expand Up @@ -589,6 +591,7 @@ export async function setupServer(
// Include all implict dependencies from the external packages internal option
include: externalMetadata.implicitServer,
ssr: true,
aot,
prebundleTransformer,
zoneless,
target,
Expand Down Expand Up @@ -625,6 +628,7 @@ export async function setupServer(
zoneless,
loader: prebundleLoaderExtensions,
thirdPartySourcemaps,
aot,
}),
};

Expand Down Expand Up @@ -663,6 +667,7 @@ function getDepOptimizationConfig({
ssr,
loader,
thirdPartySourcemaps,
aot,
}: {
disabled: boolean;
exclude: string[];
Expand All @@ -673,6 +678,7 @@ function getDepOptimizationConfig({
zoneless: boolean;
loader?: EsbuildLoaderOption;
thirdPartySourcemaps: boolean;
aot: boolean;
}): DepOptimizationConfig {
const plugins: ViteEsBuildPlugin[] = [
{
Expand Down Expand Up @@ -704,6 +710,9 @@ function getDepOptimizationConfig({
supported: getFeatureSupport(target, zoneless),
plugins,
loader,
define: {
'ngJitMode': aot ? 'false' : 'true',
},
resolveExtensions: ['.mjs', '.js', '.cjs'],
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ts_library(
prodmode_module = "es2015",
deps = [
"@npm//@angular/core",
"@npm//@angular/platform-browser",
"@npm//@angular/platform-server",
"@npm//@angular/router",
"@npm//@types/node",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ɵwhenStable as whenStable,
ɵConsole,
} from '@angular/core';
import { BootstrapContext } from '@angular/platform-browser';
import {
INITIAL_CONFIG,
ɵINTERNAL_SERVER_PLATFORM_PROVIDERS as INTERNAL_SERVER_PLATFORM_PROVIDERS,
Expand Down Expand Up @@ -76,7 +77,7 @@ async function* getRoutesFromRouterConfig(
}

export async function* extractRoutes(
bootstrapAppFnOrModule: (() => Promise<ApplicationRef>) | Type<unknown>,
bootstrapAppFnOrModule: ((context: BootstrapContext) => Promise<ApplicationRef>) | Type<unknown>,
document: string,
): AsyncIterableIterator<RouterResult> {
const platformRef = createPlatformFactory(platformCore, 'server', [
Expand Down Expand Up @@ -106,7 +107,7 @@ export async function* extractRoutes(
try {
let applicationRef: ApplicationRef;
if (isBootstrapFn(bootstrapAppFnOrModule)) {
applicationRef = await bootstrapAppFnOrModule();
applicationRef = await bootstrapAppFnOrModule({ platformRef });
} else {
const moduleRef = await platformRef.bootstrapModule(bootstrapAppFnOrModule);
applicationRef = moduleRef.injector.get(ApplicationRef);
Expand All @@ -131,7 +132,9 @@ export async function* extractRoutes(
}
}

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 @@ -8,11 +8,12 @@

import type { ApplicationRef, Type, ɵConsole } from '@angular/core';
import type { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';
import type { BootstrapContext } from '@angular/platform-browser';

Check failure on line 11 in packages/angular/build/src/utils/server-rendering/main-bundle-exports.ts

View workflow job for this annotation

GitHub Actions / lint

`@angular/platform-browser` type import should occur before type import of `@angular/platform-server`
import type { extractRoutes } from '../routes-extractor/extractor';

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

export interface RenderUtilsServerBundleExports {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import type { ApplicationRef, StaticProvider } from '@angular/core';
import type { BootstrapContext } from '@angular/platform-browser';
import assert from 'node:assert';
import { basename } from 'node:path';
import { loadEsmModuleFromMemory } from './load-esm-from-memory';
Expand Down Expand Up @@ -139,7 +140,9 @@ export async function renderPage({
};
}

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);
}
3 changes: 2 additions & 1 deletion packages/angular/ssr/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("//tools:defaults.bzl", "ng_package", "ts_library")
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")

package(default_visibility = ["//visibility:public"])

Expand All @@ -14,6 +14,7 @@ ts_library(
module_name = "@angular/ssr",
deps = [
"@npm//@angular/core",
"@npm//@angular/platform-browser",
"@npm//@angular/platform-server",
"@npm//@types/node",
"@npm//critters",
Expand Down
Loading
Loading