Skip to content

Commit 128bfda

Browse files
build: require firebase ^12.18.0 and wrap the functions it adds
The generated src/<module>/firebase.ts files are written from the type declarations of whatever firebase is installed, so the set of functions AngularFire wraps is decided by the version the build resolves. That was 12.4.0 while npm latest reached 12.18.0, leaving newly added functions reaching callers through the star export with no zone integration and no pending-task registration. Raising the required version wraps them. Everything the override entries in #3759 classified as unwrapped stays out. getImagenModel loses its entry because firebase removed the symbol in 12.18.0, so the generator no longer sees it. The exemption list it sat in is empty now and stays as the place the next unclassified name goes. Fixes #3756
1 parent e578ccb commit 128bfda

11 files changed

Lines changed: 669 additions & 591 deletions

File tree

‎docs/messaging.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ There are two parts to Firebase Messaging, a Service Worker and the DOM API. Ang
5656
It may be wise to use file replacements or environments here for different environments
5757

5858
```
59-
// This sample application is using 12.4.0, make sure you are importing the same version
59+
/* Replace <firebase-version> with the firebase version in your package.json. The service
60+
* worker and your application have to load the same version. */
6061
61-
import { initializeApp } from "https://www.gstatic.com/firebasejs/12.4.0/firebase-app.js";
62-
import { getMessaging } from "https://www.gstatic.com/firebasejs/12.4.0/firebase-messaging-sw.js";
62+
import { initializeApp } from "https://www.gstatic.com/firebasejs/<firebase-version>/firebase-app.js";
63+
import { getMessaging } from "https://www.gstatic.com/firebasejs/<firebase-version>/firebase-messaging-sw.js";
6364
6465
const firebaseApp = initializeApp({
6566
apiKey: "",

‎docs/version-21-upgrade.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ng update @angular/fire # then AngularFire 21
1111

1212
`ng update @angular/fire` runs a migration that:
1313

14-
- **Aligns your `firebase` dependency to `^12.4.0`.** AngularFire 21 requires Firebase JS SDK 12. If your app still requested `firebase` 11, npm would install both 11 and 12 side by side, and the two copies reject each other's objects at runtime. The migration updates the dependency and reinstalls so you end up with a single copy. Verify with `npm ls firebase`.
14+
- **Aligns your `firebase` dependency to `^12.18.0`.** AngularFire 21 requires Firebase JS SDK 12, at 12.18 or later. If your app requested an older `firebase`, whether that is 11 or an earlier 12, npm would install both that copy and the one AngularFire needs side by side, and the two copies reject each other's objects at runtime. The migration updates the dependency and reinstalls so you end up with a single copy. Verify with `npm ls firebase`.
1515
- **Rewrites Vertex AI imports to AI Logic** (see below).
1616

1717
## Vertex AI is now Firebase AI Logic

‎package-lock.json‎

Lines changed: 319 additions & 278 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"@angular/router": "^21.0.0",
6363
"@schematics/angular": "^21.0.0",
6464
"esbuild": "^0.24.0",
65-
"firebase": "^12.4.0",
65+
"firebase": "^12.18.0",
6666
"firebase-admin": "^13.0.0",
6767
"firebase-functions": "^6.1.1",
6868
"fs-extra": "^8.0.1",

‎sample/package-lock.json‎

Lines changed: 311 additions & 280 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎sample/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@angular/ssr": "^21.0.0",
2323
"cookie-parser": "^1.4.7",
2424
"express": "^5.1.0",
25-
"firebase": "^12.4.0",
25+
"firebase": "^12.18.0",
2626
"firebase-admin": "^13.0.1",
2727
"js-cookie": "^3.0.5",
2828
"rxjs": "~7.8.0",

‎src/messaging/firebase.ts‎

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"typescript": { "optional": true }
4242
},
4343
"dependencies": {
44-
"firebase": "^12.4.0",
44+
"firebase": "^12.18.0",
4545
"rxfire": "^6.2.0",
4646
"@angular-devkit/architect": ">= 0.2100.0 < 0.2200.0",
4747
"@angular-devkit/core": "^21.0.0",

‎src/schematics/common.jasmine.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
import { readFileSync } from 'fs';
22
import { logging } from '@angular-devkit/core';
33
import { HostTree, SchematicContext } from '@angular-devkit/schematics';
4+
import { minVersion as semverMinVersion } from 'semver';
45
import { alignFirebaseVersion, firebaseVersionRange, pinInstalledPrereleaseVersion } from './common.js';
56
import 'jasmine';
67

78
const context = { logger: new logging.Logger('test') } as unknown as SchematicContext;
89

10+
// The version a workspace already declares, written into the test package.json below.
11+
const lowestRequiredVersion = semverMinVersion(firebaseVersionRange);
12+
if (!lowestRequiredVersion) {
13+
throw new Error(`firebaseVersionRange ${firebaseVersionRange} matches no version`);
14+
}
15+
const alreadySupportedRange = `~${lowestRequiredVersion.version}`;
16+
917
const treeWithAngularFire = (declaredVersion: string, section = 'dependencies') => {
1018
const tree = new HostTree();
1119
tree.create('package.json', JSON.stringify({
1220
name: 'test-app',
1321
[section]: {
1422
'@angular/fire': declaredVersion,
15-
firebase: '^12.4.0',
23+
firebase: firebaseVersionRange,
1624
},
1725
}, null, 2));
1826
return tree;
@@ -40,7 +48,7 @@ describe('pinInstalledPrereleaseVersion', () => {
4048
it('leaves other dependencies untouched when pinning', () => {
4149
const tree = treeWithAngularFire('^21.0.0-rc.0');
4250
pinInstalledPrereleaseVersion(tree, context, '21.0.0-rc.0');
43-
expect(dependenciesIn(tree).firebase).toBe('^12.4.0');
51+
expect(dependenciesIn(tree).firebase).toBe(firebaseVersionRange);
4452
});
4553

4654
it('leaves a stable caret range untouched', () => {
@@ -148,9 +156,9 @@ describe('alignFirebaseVersion', () => {
148156
});
149157

150158
it('leaves a compatible range untouched', () => {
151-
const tree = treeWithFirebase('^12.6.0');
159+
const tree = treeWithFirebase(alreadySupportedRange);
152160
expect(alignFirebaseVersion(tree, context)).toBeFalse();
153-
expect(dependenciesIn(tree).firebase).toBe('^12.6.0');
161+
expect(dependenciesIn(tree).firebase).toBe(alreadySupportedRange);
154162
});
155163

156164
it('adds firebase when the workspace has none', () => {
@@ -198,11 +206,11 @@ describe('alignFirebaseVersion', () => {
198206
const tree = new HostTree();
199207
tree.create('package.json', JSON.stringify({
200208
name: 'test-app',
201-
dependencies: { firebase: '^12.6.0' },
209+
dependencies: { firebase: alreadySupportedRange },
202210
devDependencies: { firebase: '^11.0.0' },
203211
}, null, 2));
204212
expect(alignFirebaseVersion(tree, context)).toBeTrue();
205-
expect(dependenciesIn(tree).firebase).toBe('^12.6.0');
213+
expect(dependenciesIn(tree).firebase).toBe(alreadySupportedRange);
206214
expect(sectionIn(tree, 'devDependencies').firebase).toBe(firebaseVersionRange);
207215
});
208216

‎src/schematics/common.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ export const addDependencies = (
7272
overwriteIfExists(host, 'package.json', stringifyFormatted(packageJson));
7373
};
7474

75-
// Must stay identical to `dependencies.firebase` in `src/package.json`: if the two drift, the
76-
// alignment below can pin workspaces outside the range the library actually installs against,
77-
// re-creating the duplicate-SDK trees it exists to prevent.
78-
export const firebaseVersionRange = '^12.4.0';
75+
/* Must stay identical to `dependencies.firebase` in `src/package.json`: if the two drift, the
76+
* alignment below can pin workspaces outside the range the library actually installs against,
77+
* re-creating duplicate-SDK trees. */
78+
export const firebaseVersionRange = '^12.18.0';
7979

8080
/**
8181
* Aligns the workspace's `firebase` entry with the range `@angular/fire` requires.

0 commit comments

Comments
 (0)