angular/integration/platform-server-zoneless
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
..
e2e refactor: replace port 4206 usage with 4209 (#61362) 2025-05-15 10:12:44 -07:00
projects/standalone feat(core): introduce BootstrapContext for improved server bootstrapping (#63562) 2025-09-09 10:57:09 -07:00
.editorconfig test: add integration test for platform-server with zoneless (#61040) 2025-04-30 12:37:01 -07:00
.gitignore test: add integration test for platform-server with zoneless (#61040) 2025-04-30 12:37:01 -07:00
angular.json refactor: replace port 4206 usage with 4209 (#61362) 2025-05-15 10:12:44 -07:00
BUILD.bazel test: add integration test for platform-server with zoneless (#61040) 2025-04-30 12:37:01 -07:00
package.json test: add integration test for platform-server with zoneless (#61040) 2025-04-30 12:37:01 -07:00
README.md test: add integration test for platform-server with zoneless (#61040) 2025-04-30 12:37:01 -07:00
tsconfig.json test: add integration test for platform-server with zoneless (#61040) 2025-04-30 12:37:01 -07:00
yarn.lock test: use zone from npm instead of the locally built package for integration tests (#61947) 2025-06-06 15:20:11 -07:00

PlatformServer

This project was generated with Angular CLI version 16.0.0-rc.0.

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.