mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
This commit introduces a number of changes to the server bootstrapping process to make it more robust and less error-prone, especially for concurrent requests. Previously, the server rendering process relied on a module-level global platform injector. This could lead to issues in server-side rendering environments where multiple requests are processed concurrently, as they could inadvertently share or overwrite the global injector state. The new approach introduces a `BootstrapContext` that is passed to the `bootstrapApplication` function. This context provides a platform reference that is scoped to the individual request, ensuring that each server-side render has an isolated platform injector. This prevents state leakage between concurrent requests and makes the overall process more reliable. BREAKING CHANGE: The server-side bootstrapping process has been changed to eliminate the reliance on a global platform injector. Before: ```ts const bootstrap = () => bootstrapApplication(AppComponent, config); ``` After: ```ts const bootstrap = (context: BootstrapContext) => bootstrapApplication(AppComponent, config, context); ``` A schematic is provided to automatically update `main.server.ts` files to pass the `BootstrapContext` to the `bootstrapApplication` call. In addition, `getPlatform()` and `destroyPlatform()` will now return `null` and be a no-op respectively when running in a server environment. (cherry picked from commit 8bf80c9d2314b4f2bcf3df83ae01552a6fc49834) PR Close #63636
163 lines
5.4 KiB
Text
163 lines
5.4 KiB
Text
load("@aspect_rules_js//js:defs.bzl", "js_library")
|
|
load("@npm//:rollup/package_json.bzl", rollup = "bin")
|
|
load("//tools:defaults.bzl", "npm_package", "ts_config")
|
|
|
|
exports_files([
|
|
"tsconfig.json",
|
|
"migrations.json",
|
|
"collection.json",
|
|
])
|
|
|
|
js_library(
|
|
name = "schematics_jsons",
|
|
srcs = [
|
|
"collection.json",
|
|
"migrations.json",
|
|
"tsconfig.json",
|
|
],
|
|
visibility = ["//packages/core/schematics:__subpackages__"],
|
|
)
|
|
|
|
ts_config(
|
|
name = "tsconfig_build",
|
|
src = "tsconfig.json",
|
|
visibility = ["//packages/core/schematics:__subpackages__"],
|
|
deps = [
|
|
"//:node_modules/@types/node",
|
|
],
|
|
)
|
|
|
|
ts_config(
|
|
name = "tsconfig_test",
|
|
src = "tsconfig-test.json",
|
|
visibility = ["//packages/core/schematics:__subpackages__"],
|
|
deps = [
|
|
":tsconfig_build",
|
|
"//:node_modules/@types/jasmine",
|
|
],
|
|
)
|
|
|
|
npm_package(
|
|
srcs = [
|
|
"collection.json",
|
|
"migrations.json",
|
|
":bundles",
|
|
"//packages/core/schematics/migrations/control-flow-migration:static_files",
|
|
"//packages/core/schematics/ng-generate/cleanup-unused-imports:static_files",
|
|
"//packages/core/schematics/ng-generate/inject-migration:static_files",
|
|
"//packages/core/schematics/ng-generate/output-migration:static_files",
|
|
"//packages/core/schematics/ng-generate/route-lazy-loading:static_files",
|
|
"//packages/core/schematics/ng-generate/self-closing-tags-migration:static_files",
|
|
"//packages/core/schematics/ng-generate/signal-input-migration:static_files",
|
|
"//packages/core/schematics/ng-generate/signal-queries-migration:static_files",
|
|
"//packages/core/schematics/ng-generate/signals:static_files",
|
|
"//packages/core/schematics/ng-generate/standalone-migration:static_files",
|
|
],
|
|
visibility = ["//packages/core:__pkg__"],
|
|
)
|
|
|
|
bundle_entrypoints = [
|
|
[
|
|
"inject-migration",
|
|
"packages/core/schematics/ng-generate/inject-migration/index.js",
|
|
],
|
|
[
|
|
"route-lazy-loading",
|
|
"packages/core/schematics/ng-generate/route-lazy-loading/index.js",
|
|
],
|
|
[
|
|
"standalone-migration",
|
|
"packages/core/schematics/ng-generate/standalone-migration/index.js",
|
|
],
|
|
[
|
|
"cleanup-unused-imports",
|
|
"packages/core/schematics/ng-generate/cleanup-unused-imports/index.js",
|
|
],
|
|
[
|
|
"signals",
|
|
"packages/core/schematics/ng-generate/signals/index.js",
|
|
],
|
|
[
|
|
"signal-input-migration",
|
|
"packages/core/schematics/ng-generate/signal-input-migration/index.js",
|
|
],
|
|
[
|
|
"signal-queries-migration",
|
|
"packages/core/schematics/ng-generate/signal-queries-migration/index.js",
|
|
],
|
|
[
|
|
"output-migration",
|
|
"packages/core/schematics/ng-generate/output-migration/index.js",
|
|
],
|
|
[
|
|
"self-closing-tags-migration",
|
|
"packages/core/schematics/ng-generate/self-closing-tags-migration/index.js",
|
|
],
|
|
[
|
|
"inject-flags",
|
|
"packages/core/schematics/migrations/inject-flags/index.js",
|
|
],
|
|
[
|
|
"test-bed-get",
|
|
"packages/core/schematics/migrations/test-bed-get/index.js",
|
|
],
|
|
[
|
|
"document-core",
|
|
"packages/core/schematics/migrations/document-core/index.js",
|
|
],
|
|
[
|
|
"control-flow-migration",
|
|
"packages/core/schematics/migrations/control-flow-migration/index.js",
|
|
],
|
|
[
|
|
"router-current-navigation",
|
|
"packages/core/schematics/migrations/router-current-navigation/index.js",
|
|
],
|
|
[
|
|
"add-bootstrap-context-to-server-main",
|
|
"packages/core/schematics/migrations/add-bootstrap-context-to-server-main/index.js",
|
|
],
|
|
]
|
|
|
|
rollup.rollup(
|
|
name = "bundles",
|
|
srcs = [
|
|
"rollup.config.js",
|
|
"//:node_modules/@rollup/plugin-commonjs",
|
|
"//:node_modules/@rollup/plugin-node-resolve",
|
|
"//:node_modules/magic-string",
|
|
"//:node_modules/semver",
|
|
"//packages/core/schematics:tsconfig_build",
|
|
"//packages/core/schematics/migrations/add-bootstrap-context-to-server-main",
|
|
"//packages/core/schematics/migrations/control-flow-migration",
|
|
"//packages/core/schematics/migrations/document-core",
|
|
"//packages/core/schematics/migrations/inject-flags",
|
|
"//packages/core/schematics/migrations/router-current-navigation",
|
|
"//packages/core/schematics/migrations/test-bed-get",
|
|
"//packages/core/schematics/ng-generate/cleanup-unused-imports",
|
|
"//packages/core/schematics/ng-generate/inject-migration",
|
|
"//packages/core/schematics/ng-generate/output-migration",
|
|
"//packages/core/schematics/ng-generate/route-lazy-loading",
|
|
"//packages/core/schematics/ng-generate/self-closing-tags-migration",
|
|
"//packages/core/schematics/ng-generate/signal-input-migration",
|
|
"//packages/core/schematics/ng-generate/signal-queries-migration",
|
|
"//packages/core/schematics/ng-generate/signals",
|
|
"//packages/core/schematics/ng-generate/standalone-migration",
|
|
"//tools/bazel/rollup:path-plugin",
|
|
],
|
|
args = [
|
|
"--format=cjs",
|
|
"--config=$(rootpath rollup.config.js)",
|
|
"--dir=packages/core/schematics/bundles",
|
|
"--no-sourcemap",
|
|
] + ["--input=%s=%s" % (name, path) for [
|
|
name,
|
|
path,
|
|
] in bundle_entrypoints],
|
|
out_dirs = [
|
|
"bundles",
|
|
],
|
|
visibility = [
|
|
"//packages/core/schematics/test:__pkg__",
|
|
],
|
|
)
|