fix(schematics): align the workspace firebase dependency with the supported range#3722
Open
armando-navarro wants to merge 1 commit into
Open
fix(schematics): align the workspace firebase dependency with the supported range#3722armando-navarro wants to merge 1 commit into
armando-navarro wants to merge 1 commit into
Conversation
…ported range Upgrading an app whose own package.json still pins firebase 11 leaves npm building a tree with two firebase SDK copies: the stale one at the root (rxfire binds to it) and a second nested under @angular/fire. No install-time error fires, and the two copies reject each other's objects at runtime; angular#3684, angular#3681, and angular#3682 are all this one failure. A shared alignFirebaseVersion helper now runs in both places the schematics touch a project: ng add writes or realigns the firebase entry before its install task, and a new migration-v21 does the same during ng update, gated so a re-run on rc-to-stable updates is a no-op (the CLI strips the prerelease from the migration range's upper bound, so the migration re-executes on those transitions). Ranges not entirely inside ^12.4.0 are rewritten via semver.subset; intersects would keep ranges like ^12.0.0 or >=11 that a stale lockfile still resolves below the floor. Non-semver specifiers (dist-tags, workspace:, git URLs) are warned about, never rewritten. The ^12.4.0 constant deliberately duplicates dependencies.firebase from src/package.json rather than deriving it at build time: the build's version-injection machinery (versions.json) is under discussion in angular#3715, so this stays the minimal bridge that machinery can later supersede. A spec reads src/package.json and fails the suite if the two values ever drift. Refs angular#3684 Refs angular#3681 Refs angular#3682
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
Refsrather thanFixes: no published build carries the change until the next release is cut or a canary is published, so the issues should close when reporters can actually install the fix.)ng addprint a one-line explanation whenever they change anything, and the v21 upgrade documentation is tracked with the release notes.src/package.json, and the migration's install-task behavior).yarn install,yarn testrun successfully? Yes;npm run buildand the node test suites run green locally (55 specs), and the migration was verified end-to-end against a packed build (below).Description
Upgrading an app to
@angular/fire21 while its ownpackage.jsonstill requestsfirebase@11produces an install with two copies of the firebase SDK: npm keeps 11 at the root and nests 12 under@angular/fire. No install-time error fires, and the two copies reject each other's objects at runtime. #3684, #3681, and #3682 are all this one failure (analysis and reproductions in those threads).This PR makes the schematics keep the workspace's
firebaseentry aligned with the range the library requires:alignFirebaseVersionhelper andfirebaseVersionRangeconstant insrc/schematics/common.ts;ng addwrites the entry when missing and realigns an incompatible one before its install task runs;migration-v21runs the same alignment duringng update @angular/fire, scheduling an install only when it changed something (the CLI re-runs the migration on rc-to-stable updates, so the no-op path matters).Behavior details:
^12.4.0(semver.subset);intersectswould keep ranges like^12.0.0or>=11that a stale lockfile still resolves below the required floor.workspace:,file:, git URLs) are never rewritten; the user gets a warning explaining the risk instead.firebaseVersionRangeintentionally duplicatesdependencies.firebasefromsrc/package.jsoninstead of being injected at build time: the build's version-injection machinery (versions.json) is under discussion in TheANGULARFIRE2_VERSIONbuild placeholder ships unreplaced in the library, andversions.jsonnever reaches the compiled schematics #3715, so the constant is the minimal bridge that machinery can later supersede. A spec readssrc/package.jsonand fails the suite if the two values ever drift.Verified end-to-end against a packed build. A fixture app with
firebase@11.8.0installed next to this package (the exact broken tree from the linked issues), thenng update @angular/fire --migrate-only --from=20.0.1:npm ls firebaseafterwards shows a singlefirebase@12.16.0, and a second run reports "Migration completed (No changes made)".