You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 29ca012
Browse filesBrowse the repository at this point in the historyBrowse files
build!: make firebase a peer dependency and add the v22 migration (#3805)
Through 21, @angular/fire listed firebase under dependencies, so an app
that asked for a different version got a second copy nested under
@angular/fire, and the two copies rejected each other's objects at
runtime (#3684, #3681, #3682 and six more). As a peer dependency there
is exactly one copy: npm refuses an incompatible range with ERESOLVE
before installing anything, and pnpm and yarn install one copy with a
warning.
ng update rewrites a firebase entry the app already declares but adds
none to an app without one, so migration-v22 calls alignFirebaseVersion
and reinstalls only when it changed something. The comment and the two
messages in alignFirebaseVersion no longer say that @angular/fire
bundles its own firebase, and the firebaseVersionRange spec reads the
peer entry. The duplicate-firebase warning from ng add stays: two copies
still appear when another package bundles its own firebase.
docs/version-22-upgrade.md starts with this change, naming the canary
tag until a release candidate exists. The guide states the exact range
the migration writes (^12.18.0) and quotes pnpm's unmet-peer warning as
pnpm 9 and 10 print it and as pnpm 11 and 12 print it.
BREAKING CHANGE: firebase is a peer dependency. Apps must declare
firebase ^12.18.0 in their own package.json. ng update @angular/fire
adds it when missing. A firebase outside that range now fails to install
on npm (ERESOLVE) instead of installing a second copy.
Fixes#3804
Refs #3684, #3681, #3682
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,8 @@ export class App {
75
75
76
76
[Upgrading from AngularFire 20? See the v21 upgrade guide.](docs/version-21-upgrade.md)
77
77
78
+
[Upgrading from AngularFire 21? See the v22 upgrade guide.](docs/version-22-upgrade.md)
79
+
78
80
### Sample app
79
81
80
82
The [`sample`](sample) folder contains a kitchen sink application that demonstrates use of the "modular" API, in a zoneless server-rendered application, with all the bells and whistles.
AngularFire 22 targets **Angular 22** and the **Firebase JS SDK v12**. Most of the upgrade is handled for you by `ng update`.
4
+
5
+
## Run the update
6
+
7
+
AngularFire 22 is published under the `canary` tag, a build of every merge to `main`, until a release candidate is published under `next`. From an app on Angular 21 and AngularFire 21, run:
8
+
9
+
```bash
10
+
ng update @angular/core@22 @angular/cli@22 @angular/fire@canary
11
+
```
12
+
13
+
Include `@angular/fire@canary` in the same command as Angular. On its own, `ng update @angular/core@22 @angular/cli@22` refuses to run while AngularFire 21 is installed, because AngularFire 21 only accepts Angular 21.
14
+
15
+
The AngularFire update runs a migration that:
16
+
17
+
-**Adds**`firebase`**to your**`package.json`**if it is missing**, as `"firebase": "^12.18.0"`, and reinstalls. See the next section for why.
18
+
-**Aligns an existing**`firebase`**entry to**`^12.18.0` when it requests a version outside that range.
19
+
20
+
## Your app now owns the Firebase SDK
21
+
22
+
Through AngularFire 21, `@angular/fire` listed `firebase` under `dependencies`, so npm could install a second copy of the SDK under `node_modules/` whenever your app asked for a different version. The two copies reject each other's objects at runtime, with errors such as `Expected type '_Query', but it was: a custom _CollectionReference object` or `toDate is not a function`.
23
+
24
+
AngularFire 22 lists `firebase` under `peerDependencies` instead. So your app should declare `firebase` in its `package.json` (on Yarn it must, since Yarn installs no peer dependencies). This gives you exactly one copy of `firebase`, and an incompatible version is refused at install time instead of failing at runtime.
25
+
26
+
`ng update @angular/fire@canary` updates an older `firebase` entry in your `package.json` to `^12.18.0` when it requests a version outside that range. If your app doesn't list `firebase` in `package.json` the migration adds `"firebase": "^12.18.0"` and reinstalls. Verify with `npm ls firebase`, which should show exactly one copy.
27
+
28
+
### If you install with `npm install` instead of `ng update`
npm 7 and later install a missing peer dependency automatically, so `npm install @angular/fire@canary` alone also works, but it does not write `firebase` into your `package.json`. Declare it so that a later install cannot change which version you get.
37
+
38
+
### If npm stops with `ERESOLVE`
39
+
40
+
An app that requests a `firebase` version outside the range AngularFire 22 supports now fails to install with an `ERESOLVE` error. Update your `firebase` entry to a version inside the range given in the error message, then install again:
41
+
42
+
```bash
43
+
npm install firebase@^12.18.0
44
+
```
45
+
46
+
Do not use `--force` or `--legacy-peer-deps` to get past this message. Both install the older SDK next to AngularFire 22 and the runtime errors described above come back. If your project has `legacy-peer-deps=true` in its `.npmrc`, remove it before upgrading.
47
+
48
+
### Yarn
49
+
50
+
Yarn doesn't install peer dependencies. Add `firebase` to your own `package.json` as shown above, or run `ng update @angular/fire@canary`, which adds it.
51
+
52
+
An older version installs anyway with a warning (`has incorrect peer dependency "firebase@^12.18.0"` on Yarn 1, `YN0060: INCOMPATIBLE_PEER_DEPENDENCY` on Yarn 2+), so treat that warning as an upgrade step you still have to do.
53
+
54
+
### pnpm
55
+
56
+
pnpm 8 and later install a missing `firebase` automatically. An older version installs anyway with a warning (`unmet peer firebase@^12.18.0: found 11.x` on pnpm 9 and 10, `Issues with peer dependencies found. Run "pnpm peers check" to list them.` on pnpm 11 and 12), and pnpm prints that warning only once, when it first resolves the tree, never on a later install from the committed lockfile.
57
+
58
+
Set `strict-peer-dependencies=true` in `.npmrc` to make pnpm refuse the mismatch outright.
Copy file name to clipboardExpand all lines: src/schematics/migration.json
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,13 @@
8
8
},
9
9
"migration-v21": {
10
10
"version": "21.0.0",
11
-
"description": "Align the workspace's firebase dependency with the range @angular/fire 21 requires, and rewrite Vertex AI imports to Firebase AI Logic (getVertexAI callers keep the same backend, and a call that passed no location moves from us-central1 to global)",
11
+
"description": "Align the workspace's firebase dependency with the range @angular/fire requires, and rewrite Vertex AI imports to Firebase AI Logic (getVertexAI callers keep the same backend, and a call that passed no location moves from us-central1 to global)",
12
12
"factory": "./update/v21#ngUpdate"
13
+
},
14
+
"migration-v22": {
15
+
"version": "22.0.0",
16
+
"description": "Add firebase to the workspace's package.json when it is missing, now that @angular/fire lists it as a peer dependency, and align an existing entry with the range @angular/fire requires",
0 commit comments