Skip to content

Commit fa0fa6e

Browse files
chore(sample): update the sample app to Angular 22 (#3845)
Carries sample/ from Angular 21 to 22 with ng update, matching what ng new 22 generates: TypeScript 6, firebase 13, vitest 5, Node 24, provideBrowserGlobalErrorListeners, no explicit zoneless provider and no withIncrementalHydration (both are defaults now), the Eager change detection the migration adds removed again so the components run on the OnPush default. The server app is now built by initializeBrowserOrServerApp, which reads the ID token from the request context and releases the server app after the render. The old factory never released it. Calls to functions AngularFire does not wrap sit outside runInInjectionContext, with a comment on each, so the sample shows where the injection context is needed and where it is not. security.allowedHosts gains localhost: Angular 22 answers 400 to any host not on the list, so the built server could not be run locally. Both lockfiles regenerated with npm 10. Refs #3669
1 parent 74abd5a commit fa0fa6e

18 files changed

Lines changed: 7779 additions & 7702 deletions

‎sample/README.md‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
# AngularFire 21 Sample App
1+
# AngularFire 22 Sample App
22

3-
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.0.0.
3+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 22.2.6.
4+
5+
## Node.js
6+
7+
Use Node.js 24.15 or later for every command below. The sample declares `firebase` 13, whose packages require Node.js 24.12 or later, and Angular 22 requires 24.15 on that line. On Node.js 22.22.3 or later the install still works but prints `EBADENGINE` warnings for the `firebase` packages.
48

59
## AngularFire tarball
610

7-
The sample consumes the library as `file:../angular-fire-21.0.0.tgz`. Produce that file from the repository root before installing here:
11+
The sample consumes the library as `file:../angular-fire-22.0.0.tgz`. Produce that file from the repository root before installing here:
812

913
```bash
1014
npm ci
@@ -16,7 +20,7 @@ The root build ends with `npm pack ./dist/packages-dist`, which writes `angular-
1620
Then, from this `sample/` folder, install the dependencies by naming the tarball explicitly:
1721

1822
```bash
19-
npm install ../angular-fire-21.0.0.tgz
23+
npm install ../angular-fire-22.0.0.tgz
2024
```
2125

2226
A plain `npm install` is not reliable here. `package-lock.json` records the integrity hash of the tarball built by whoever committed the lockfile, and a tarball you build yourself can hash differently. With a cold npm cache the install then fails with an `EINTEGRITY` error. With a warm cache that holds the recorded hash, npm installs the stale cached copy and exits successfully, so you would be testing a library you did not build. Naming the tarball installs the file on disk and rewrites the recorded hash in your local `package-lock.json`. Leave that lockfile change uncommitted.
@@ -65,6 +69,10 @@ ng build
6569

6670
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
6771

72+
## Running the server build
73+
74+
`npm run serve:ssr:ng22-test` starts the built Express server on port 4000. Angular 22 answers `400 Bad Request` to any host it was not told about, and `angular.json` allows only `localhost` (`security.allowedHosts`). A deployment adds its own hostnames there or in the `NG_ALLOWED_HOSTS` environment variable.
75+
6876
## Running unit tests
6977

7078
To execute unit tests with [Vitest](https://vitest.dev), use the following command:

‎sample/angular.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": 1,
44
"newProjectRoot": "projects",
55
"projects": {
6-
"ng21-test": {
6+
"ng22-test": {
77
"projectType": "application",
88
"schematics": {},
99
"root": "",
@@ -28,7 +28,7 @@
2828
"server": "src/main.server.ts",
2929
"outputMode": "server",
3030
"security": {
31-
"allowedHosts": []
31+
"allowedHosts": ["localhost"]
3232
},
3333
"ssr": {
3434
"entry": "src/server.ts"
@@ -63,10 +63,10 @@
6363
"builder": "@angular/build:dev-server",
6464
"configurations": {
6565
"production": {
66-
"buildTarget": "ng21-test:build:production"
66+
"buildTarget": "ng22-test:build:production"
6767
},
6868
"development": {
69-
"buildTarget": "ng21-test:build:development"
69+
"buildTarget": "ng22-test:build:development"
7070
}
7171
},
7272
"defaultConfiguration": "development"

0 commit comments

Comments
 (0)