-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Bundle includes unused firebase modules (#3366)
* fix: Bundle includes unused firebase modules `@angular/fire` core package always import these packages - firebase/remote-config - firebase/messaging - firebase/analytics which increase the total bundle size for any application using `@angular/fire` Fix #3075 * Update src/remote-config/is-remote-config-supported-factory.ts * Update src/messaging/is-messaging-supported-factory.ts * Update src/analytics/is-analytics-supported-factory.ts --------- Co-authored-by: David East <davideast@users.noreply.github.com>
- Loading branch information
1 parent
a26980b
commit 34e89a4
Showing
10 changed files
with
82 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ɵisSupportedError } from '@angular/fire'; | ||
import { isSupported } from 'firebase/analytics'; | ||
|
||
const isAnalyticsSupportedValueSymbol = '__angularfire_symbol__analyticsIsSupportedValue'; | ||
const isAnalyticsSupportedPromiseSymbol = '__angularfire_symbol__analyticsIsSupported'; | ||
|
||
globalThis[isAnalyticsSupportedPromiseSymbol] ||= isSupported().then(it => | ||
globalThis[isAnalyticsSupportedValueSymbol] = it | ||
).catch(() => | ||
globalThis[isAnalyticsSupportedValueSymbol] = false | ||
); | ||
export const isAnalyticsSupportedFactory = { | ||
async: () => globalThis[isAnalyticsSupportedPromiseSymbol], | ||
sync: () => { | ||
const ret = globalThis[isAnalyticsSupportedValueSymbol]; | ||
if (ret === undefined) { throw new Error(ɵisSupportedError('Analytics')); } | ||
return ret; | ||
} | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { ɵisAnalyticsSupportedFactory } from '@angular/fire'; | ||
import { isAnalyticsSupportedFactory } from './is-analytics-supported-factory'; | ||
|
||
export const isSupported = isAnalyticsSupportedFactory.async; | ||
|
||
export const isSupported = ɵisAnalyticsSupportedFactory.async; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ɵisSupportedError } from '@angular/fire'; | ||
import { isSupported } from 'firebase/messaging'; | ||
|
||
const isMessagingSupportedPromiseSymbol = '__angularfire_symbol__messagingIsSupported'; | ||
const isMessagingSupportedValueSymbol = '__angularfire_symbol__messagingIsSupportedValue'; | ||
|
||
globalThis[isMessagingSupportedPromiseSymbol] ||= isSupported().then(it => | ||
globalThis[isMessagingSupportedValueSymbol] = it | ||
).catch(() => | ||
globalThis[isMessagingSupportedValueSymbol] = false | ||
); | ||
|
||
export const isMessagingSupportedFactory = { | ||
async: () => globalThis[isMessagingSupportedPromiseSymbol], | ||
sync: () => { | ||
const ret = globalThis[isMessagingSupportedValueSymbol]; | ||
if (ret === undefined) { throw new Error(ɵisSupportedError('Messaging')); } | ||
return ret; | ||
} | ||
}; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { ɵisMessagingSupportedFactory } from '@angular/fire'; | ||
import { isMessagingSupportedFactory } from './is-messaging-supported-factory'; | ||
|
||
export const isSupported = ɵisMessagingSupportedFactory.async; | ||
export const isSupported = isMessagingSupportedFactory.async; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { isSupported } from 'firebase/remote-config'; | ||
import { ɵisSupportedError } from '@angular/fire'; | ||
|
||
const isRemoteConfigSupportedValueSymbol = '__angularfire_symbol__remoteConfigIsSupportedValue'; | ||
const isRemoteConfigSupportedPromiseSymbol = '__angularfire_symbol__remoteConfigIsSupported'; | ||
|
||
globalThis[isRemoteConfigSupportedPromiseSymbol] ||= isSupported().then(it => | ||
globalThis[isRemoteConfigSupportedValueSymbol] = it | ||
).catch(() => | ||
globalThis[isRemoteConfigSupportedValueSymbol] = false | ||
); | ||
|
||
export const isRemoteConfigSupportedFactory = { | ||
async: () => globalThis[isRemoteConfigSupportedPromiseSymbol], | ||
sync: () => { | ||
const ret = globalThis[isRemoteConfigSupportedValueSymbol]; | ||
if (ret === undefined) { throw new Error(ɵisSupportedError('RemoteConfig')); } | ||
return ret; | ||
} | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { ɵisRemoteConfigSupportedFactory } from '@angular/fire'; | ||
import { isRemoteConfigSupportedFactory } from './is-remote-config-supported-factory'; | ||
|
||
export const isSupported = ɵisRemoteConfigSupportedFactory.async; | ||
export const isSupported = isRemoteConfigSupportedFactory.async; |
This file contains 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