Repository navigation
Make firebase a peer dependency of @angular/fire #3804
Description
AngularFire lists firebase under dependencies, so an app that requests a different firebase version than AngularFire does gets a second copy of the SDK nested under node_modules/@angular/fire/node_modules/firebase. The two copies reject each other's objects at runtime. That is the mechanism behind #3684, #3681 and #3682 on 21.0.0-rc.0, and the same failure is in older reports such as #3245 and #3442.
Proposal
Make firebase a peer dependency in AngularFire 22, so the app owns the single copy of the SDK:
firebase ^12.18.0moves fromdependenciestopeerDependenciesin the publishedpackage.json.- A
migration-v22forng updateaddsfirebaseto the app'spackage.jsonwhen it is missing, and aligns an existing entry that is outside the range.ng updateitself updates a peer the app already declares but never adds one. The migration reuses the alignmentng addalready runs. - The v22 upgrade guide documents the change and the install-time error it produces.
What would change for apps
- On npm, a
firebaseoutside the supported range fails to install withERESOLVE, which says which two versions conflict, instead of installing a second copy that fails at runtime. - On pnpm and Yarn, an out-of-range
firebaseinstalls as one copy with a peer warning. Yarn installs no peer dependencies at all, so an app that never declaredfirebasehas to add it, which the migration does. - The
ng addwarning for two installedfirebaseversions stays. Under a peer dependency, two copies appear only when another package bundles its ownfirebase.
History
AngularFire 2.0 made firebase a peer dependency for this exact reason (#749, 2016), and 7.3.0 moved it back to dependencies (#3159, 2022). Seven of nine comparable wrapper libraries, including rxfire, reactfire and vuefire, list the SDK as a peer.
This is a breaking change, for 22.0.0.
Activity
build!: make firebase a peer dependency and add the v22 migration (an…