Repository navigation
build!: make firebase a peer dependency and add the v22 migration - #3805
Merged
Merged
Conversation
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 (angular#3684, angular#3681, angular#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. 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.
tyler-reitz
approved these changes
Oct 23, 2026
tyler-reitz
left a comment
Collaborator
There was a problem hiding this comment.
Approving. Two small doc notes, neither blocking:
docs/version-22-upgrade.mdsays the migration updates an olderfirebaseentry "to the current 12.x release". It writes^12.18.0, and only when the existing entry falls outside that range, so "to^12.18.0" would be exact.- The pnpm section says the unmet-peer warning prints "only once, when it first resolves the tree, never on a later install from the committed lockfile." Was that checked against pnpm? The verification section covers npm only, and readers will rely on that sentence.
Fine to land either as a follow-up.
The upgrade guide said the migration updates an older firebase entry "to the current 12.x release". It writes ^12.18.0, and only when the existing entry falls outside that range, so say so. The pnpm paragraph quoted the unmet-peer warning as pnpm 9 and 10 print it. pnpm 11 changed the wording to "Issues with peer dependencies found. Run "pnpm peers check" to list them." and pnpm 12 keeps that, checked against this branch's tarball on 9.15.4, 10.34.8, 11.28.8 and 12.15.0. On all four the warning prints on the first resolution only, never on a lockfile-backed install, which the paragraph already said.
Collaborator
Author
|
Thanks for the review, both notes were worth raising.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
firebasea peer dependency of@angular/fire#3804docs/version-22-upgrade.mdis new, with its README link. The README and quickstart install commands follow in their own pull request, held until 22.0.0 is published.src/schematics/update/v22/index.jasmine.ts, and thefirebaseVersionRangespec now reads the peer entry.BREAKING CHANGE:footer in the commit,!in the subject.yarn install,yarn testrun successfully? yes, with npm:npm ci,npm run build,npm run lint,npm run test:node(389 specs) andnpm run test:chrome-headless(112 specs) pass.Description
Through v21,
@angular/firelistedfirebaseunderdependencies, so an app that asked for a different version got a second copy of the SDK nested under@angular/fire, and the two copies rejected each other's objects at runtime. Withfirebaseas a peer dependency there is exactly one copy, and an incompatible version is refused at install time on npm. The reasoning and the alternatives are in #3804.Changes
src/package.json:firebase ^12.18.0moves fromdependenciestopeerDependencies.src/ng-package.jsondrops it fromallowedNonPeerDependencies.migration-v22(src/schematics/update/v22/index.ts, registered inmigration.jsonat22.0.0,tools/build.tsand the schematicstsconfig.json): callsalignFirebaseVersionand schedules an install only when it changed something.ng updaterewrites afirebaseentry the app already declares before any migration runs, but writes nothing for an app with no entry, so the migration exists for that case.ng updaterelies on across prerelease steps.alignFirebaseVersion: the comment and its two log messages no longer say that@angular/firebundlesfirebase, and they no longer describe one package manager's behavior. ThefirebaseVersionRangecomment and spec tie the literal topeerDependencies.firebase.firebaseVersionRangeconstant.docs/version-22-upgrade.md: the run-the-update command, what the migration does, and the "Your app now owns the Firebase SDK" section (npm,ERESOLVE, Yarn, pnpm). The commands say@angular/fire@canary, the only installable 22 build today, and move to@nextand@22as those tags exist.Behavior to know
firebaseentry.ng updateadds it.npm install @angular/fire@canaryby hand leaves the app working with an undeclared dependency, which the guide tells the reader to declare.firebaseas one copy with a warning, andlegacy-peer-deps=truein an.npmrcmakes npm do the same silently. Theng addandng updatealignment is what corrects those apps.ng addwarning for two installedfirebaseversions stays. Under a peer dependency, two copies appear only when another package bundles its ownfirebase.firebaserange itself (^12.18.0today,^12.19.0is a separate decision)@schematics/angularand@angular-devkit/schematicsindependencies(Move Schematic dependencies topeerDependenciesordevDependencies#3694)Verification
test:node(389 specs, four of them the new migration's) andtest:chrome-headless(112 specs) pass. The builtpackage.jsonand the packed tarball listfirebase ^12.18.0as a peer and nofirebasedependency.firebaseentry takes the packed tarball (npm 11 installs the peer, writes nothing), thenng update @angular/fire --migrate-only --from 21.0.0 --to 22.0.0addsfirebase ^12.18.0, reinstalls, andnpm ls firebaseshows one copy. The app builds with the Firestore providers wired in. A second run reports no changes.firebase ^11.0.0failsnpm installof the tarball withERESOLVE, which reportspeer firebase@"^12.18.0" from @angular/[email protected], nothing installed.Fixes #3804
Refs #3684, #3681, #3682