angular/packages/core
Alan Agius 70d0639bc1
fix(core): introduce BootstrapContext for improved server bootstrapping (#63639)
* fix(core): introduce `BootstrapContext` for improved server bootstrapping

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.
2025-09-09 10:56:38 -07:00
..
global refactor(docs-infra): use interpolation instead of innerHTML for better perf (#58913) 2024-11-27 10:59:18 +01:00
primitives build: migrate more targets of @angular/core to ts_project (#61420) 2025-05-16 15:53:27 +00:00
rxjs-interop build: migrate all ts_library in packages/core/test (#61571) 2025-05-21 16:04:42 +00:00
schematics fix(core): introduce BootstrapContext for improved server bootstrapping (#63639) 2025-09-09 10:56:38 -07:00
src fix(core): introduce BootstrapContext for improved server bootstrapping (#63639) 2025-09-09 10:56:38 -07:00
test fix(core): introduce BootstrapContext for improved server bootstrapping (#63639) 2025-09-09 10:56:38 -07:00
testing build: migrate platform-browser and platform-browser-dynamic package to use rules_js (#61624) 2025-05-22 15:32:58 -07:00
BUILD.bazel build: migrate more targets of @angular/core to ts_project (#61420) 2025-05-16 15:53:27 +00:00
index.ts refactor: update packages/core:{core,src} to ts_project (#61336) 2025-05-14 08:31:33 -07:00
package.json build: update zone.js peer dependency for core package to 0.15.0 (#57431) 2024-08-21 13:17:52 -07:00
PACKAGE.md docs: add package doc files (#26047) 2018-10-05 15:42:14 -07:00
public_api.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
tsconfig-build.json build: migrate more targets of @angular/core to ts_project (#61420) 2025-05-16 15:53:27 +00:00
tsconfig-test.json build: migrate more targets of @angular/core to ts_project (#61420) 2025-05-16 15:53:27 +00:00