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
99 changes: 99 additions & 0 deletions .github/workflows/compat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Angular compatibility

# Builds an Angular CLI app (compat/fixture) against every Angular version the
# packages claim to support, zoneless and with Zone.js, and checks that it
# streams and hydrates: compat/run.mjs. The peer ranges in packages/*/package.json
# list exactly what this matrix checks.

on:
pull_request:
paths:
- 'packages/**'
- 'compat/**'
- '.github/workflows/compat.yml'
push:
branches: [main]
paths:
- 'packages/**'
- 'compat/**'
- '.github/workflows/compat.yml'
# Every Monday, so a new Angular patch or `next` shows up before users do.
schedule:
- cron: '0 5 * * 1'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: compat-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
pack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
# The workspace needs Node 26.
- uses: actions/setup-node@v4
with:
node-version: 26
cache: pnpm
- run: pnpm install --frozen-lockfile
# The two packages an Angular CLI app installs, packed as npm would get them.
- run: |
mkdir -p packs
for name in core angular-ssr; do
(cd packages/$name && pnpm run build && pnpm pack --pack-destination ../../packs)
done
- uses: actions/upload-artifact@v4
with:
name: packs
path: packs/*.tgz

check:
needs: pack
runs-on: ubuntu-latest
# `next` is Angular's upcoming release: a failure there is a warning about
# what is coming, not a broken build.
continue-on-error: ${{ matrix.angular == 'next' }}
strategy:
fail-fast: false
matrix:
# The newest patch of each supported minor, the lowest supported patch
# of each older major, and what Angular releases next.
angular:
[
'19.2',
'19.2.22',
'20.3',
'20.3.21',
'21.2',
'21.2.13',
'22.0',
'22.1',
'22.2',
'22.3',
'next',
]
mode: [zoneless, zone]
name: Angular ${{ matrix.angular }}, ${{ matrix.mode }}
steps:
- uses: actions/checkout@v4
# Node 22 is supported by every Angular version in the matrix.
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/download-artifact@v4
with:
name: packs
path: packs
# ubuntu-latest has Chrome at /usr/bin/google-chrome.
- run: node compat/run.mjs --angular '${{ matrix.angular }}' --mode ${{ matrix.mode }} --packs packs
- if: always()
uses: actions/upload-artifact@v4
with:
name: result-${{ matrix.angular }}-${{ matrix.mode }}
path: compat/.work/*/result.json
if-no-files-found: ignore
8 changes: 8 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ together; the short version:
- **Angular version is pinned to exactly `22.3.0-rc.0`** in every project.
Do not bump any `@angular/*` package on its own; ngp imports private
`@angular/compiler-cli` APIs and only works against that exact release.
The packages themselves support more (19.2.22+, 20.3.21+, 21.2.13+, 22):
`compat/` is an Angular CLI app outside the workspace that
`node compat/run.mjs --angular <minor> --mode <zoneless|zone>` installs,
builds and checks (curl-style timing plus headless Chrome) against one
version, and `.github/workflows/compat.yml` runs it as a matrix. Change the
peer ranges only together with that matrix, and run the affected rows
locally after changing anything in `packages/core` or `packages/angular-ssr`
that touches Angular's internals.
- **Styles**: component `styleUrl` files go through Vite's Sass pipeline. Inline
`styles` are plain CSS only, no Sass there.
- **Icons (movies)**: `<fast-svg name="...">`. Adding an icon means dropping the
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ to npm under `@push-based/`:
| `packages/angular-ssr` | `@push-based/angular-ssr-stream-angular-ssr`: `withStreaming()`, for `@angular/ssr` in Angular CLI apps. |
| `apps/example-*` | One small app per runtime, all rendering `libs/stream-example`. Built in CI, not deployed. |
| `apps/example-angular-cli` | An app made by `ng new --ssr`, built by `ng build`, with `@angular/ssr` streaming. Built in CI. |
| `compat` | An Angular CLI app and the script that checks the packages against one Angular version, for CI. |
| `libs/stream-example` | `@angular-ssr-stream/stream-example`: the page every example renders, a shell and one slow widget. |
| `libs/design-system` | `@angular-ssr-stream/design-system`: the PushBased design system the demo and the docs share. Private. |
| `press-kit` | The logo in every form: symbol, lockups, favicons and the social preview, with how to use them. |
Expand Down Expand Up @@ -239,8 +240,10 @@ publishes to npm on the `next` dist-tag with provenance. The first run needs
`@push-based` scope.

The packages use private Angular APIs (`ɵ`-prefixed), so their Angular peer
range is narrow (`~22.3.0-rc.0`) and every Angular minor needs a check and a
release.
range is what `compat/` proves: an Angular CLI app, built and run against the
latest patch of every supported minor and the lowest patch of each, zoneless
and with Zone.js, by `.github/workflows/compat.yml`. A new Angular minor gets
a row in that matrix first, and joins the peer ranges once it passes.

## How the pieces fit

Expand Down
4 changes: 3 additions & 1 deletion apps/docs/src/content/concepts/angular-streaming-ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ app runs:
shell, so a part that fails afterwards cannot turn the response into an error
page or a redirect.
- **It is not part of Angular.** The library leans on Angular internals, so it
supports a narrow range of Angular versions. With the Angular CLI it works
supports the versions a check in CI proves, 19.2 to 22 today; see
[Compatibility](../getting-started/installation.md#compatibility). With the
Angular CLI it works
inside `@angular/ssr`, streaming the routes it renders on the server; every
other setup renders without `@angular/ssr`.
[Caveats and limitations](../reference/limitations.md) has the list.
Expand Down
17 changes: 17 additions & 0 deletions apps/docs/src/content/getting-started/angular-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,23 @@ piece:
Streamed responses carry `Cache-Control: no-store`, whatever the route's
headers say: a cached copy of a partial response would be worse than none.

## Angular 19 to 21

The steps above are for Angular 22, which `ng new` gives you today. On 19.2,
20.3 or 21.2, check the patch against the
[compatibility table](installation.md#compatibility), then:

- **Turn on incremental hydration.** Angular 22 does it by default; before
that, add `withIncrementalHydration()` from `@angular/platform-browser` to
`provideClientHydration()`. Without it nothing streams, and the server warns.
- **Check `main.server.ts`.** Its `bootstrap` has to take the
`BootstrapContext` it is called with and pass it to
`bootstrapApplication()`, as in step 4. `ng new` writes it that way in every
supported version, but an app made before Angular's security fix that added
it may still have a `bootstrap` that takes no argument: add it.
- **On 19**, zoneless is `provideExperimentalZonelessChangeDetection()`. Zone.js
works as well.

## 8. Behind a proxy

A proxy, a CDN or compression middleware can hold the response back until it
Expand Down
52 changes: 44 additions & 8 deletions apps/docs/src/content/getting-started/installation.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
## Requirements

- **Angular `~22.3.0-rc.0`**, standalone, with incremental hydration.
Zoneless or with Zone.js: on the server, the requests the renderer follows
run outside the Angular zone, so Zone.js doesn't hold the shell back for
them. The packages use private Angular APIs (the `ɵ`-prefixed ones), so
their supported range is narrow: each Angular minor needs a check and a
release.
- **Angular 19.2, 20.3, 21.2 or 22**, from the patch each row of
[the compatibility table](#compatibility) names, standalone, with
incremental hydration. Zoneless or with Zone.js.
- **A server that speaks web `Request` and `Response`**, directly or through
one of the adapters below.
- **A build that compiles Angular for the server**, one of two:
Expand All @@ -20,10 +17,49 @@
`AngularAppEngine`, server routes and render modes are not available; see
[Caveats and limitations](../reference/limitations.md).

## Compatibility

The packages use private Angular APIs (the `ɵ`-prefixed ones), which can
change in any release. So the supported versions are the ones a check proves,
not a guess: every row below is built and run in CI, zoneless and with
Zone.js, as an app made by the Angular CLI. The server has to send the shell
before the data and the widget in a chunk after it, with `@angular/ssr`'s
statuses, headers and redirects intact. In Chrome, the widget has to hydrate
from the server's HTML, with Angular's hydration checks on, and answer a
click.

| Angular | From | Zoneless | Zone.js | What the app needs |
| ------- | ------- | -------- | ------- | -------------------------------------------------------------------------------- |
| 22 | 22.0.0 | Yes | Yes | Nothing extra: incremental hydration is on by default |
| 21.2 | 21.2.13 | Yes | Yes | `withIncrementalHydration()` in `provideClientHydration()` |
| 20.3 | 20.3.21 | Yes | Yes | `withIncrementalHydration()` in `provideClientHydration()` |
| 19.2 | 19.2.22 | Yes | Yes | `withIncrementalHydration()`, and `provideExperimentalZonelessChangeDetection()` |

Not supported:

- **Angular 18 and older**, which have no incremental hydration.
- **19.0, 19.1, 20.0 to 20.2, 21.0 and 21.1, and the patches below each row's
"From".** They lack two security fixes Angular backported only to the last
minor of each major: the server's host check (`ɵisHostAllowed`), and passing
the server platform to `bootstrapApplication()`, which the renderer
bootstraps through.

With incremental hydration off, the server renders no `@defer` block with a
`hydrate` trigger, so nothing streams. In development the server says so in a
warning.

The ngp setups are the exception: ngp builds exactly `22.3.0-rc.0`, and no
other version.

The matrix is in `.github/workflows/compat.yml` and runs
[`compat/run.mjs`](https://github.com/push-based/angular-ssr-stream/blob/main/compat/run.mjs)
for each row, on every pull request that touches the packages, and every week
against Angular's `next` too. A new Angular minor gets a row there first, and
joins the peer ranges once it passes.

## Install

Releases go to npm's `next` dist-tag while the supported Angular is a release
candidate:
Releases go to npm's `next` dist-tag for now:

```bash
npm install @push-based/angular-ssr-stream-core@next
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/src/content/reference/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- **It leans on Angular internals**: the layout of serialized hydration data,
`ɵannotateForHydration`, the dehydrated block registry, and
`DeferBlockFixture`'s way of rendering a block. This is why the supported
Angular range is narrow.
Angular versions are the ones CI checks, listed under
[Compatibility](../getting-started/installation.md#compatibility).
- **`hydrate when` is rendered by hand on the server.** Angular renders it during
a template update, which throws `NG0600` from the second request on if the
component has signal queries. The buffered fallback cannot work around that, so
Expand Down
1 change: 1 addition & 0 deletions compat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.work/
Loading
Loading