angular/packages/core/schematics
Alan Agius 28926ba92c feat(core): introduce BootstrapContext for improved server bootstrapping (#63562)
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.

PR Close #63562
2025-09-09 10:57:09 -07:00
..
migrations feat(core): introduce BootstrapContext for improved server bootstrapping (#63562) 2025-09-09 10:57:09 -07:00
ng-generate fix(core): Fixed inject migration schematics for migrate destructured properties (#62832) 2025-09-02 10:59:46 -07:00
test feat(core): introduce BootstrapContext for improved server bootstrapping (#63562) 2025-09-09 10:57:09 -07:00
utils build: rename defaults2.bzl to defaults.bzl (#63383) 2025-08-25 15:45:01 -07:00
BUILD.bazel feat(core): introduce BootstrapContext for improved server bootstrapping (#63562) 2025-09-09 10:57:09 -07:00
collection.json feat(migrations): add migration to convert ngClass to use class (#62983) 2025-08-21 11:41:32 -07:00
migrations.json feat(core): introduce BootstrapContext for improved server bootstrapping (#63562) 2025-09-09 10:57:09 -07:00
rollup.config.js build: use rollup directory instead of rollup through @bazel/rollup (#62556) 2025-07-09 16:53:25 -07:00
tsconfig-test.json build: migrate packages/core/schematics to ts_project (#61370) 2025-05-16 11:02:07 +00:00
tsconfig.json build: migrate packages/core/schematics to ts_project (#61370) 2025-05-16 11:02:07 +00:00