16
16
*/
17
17
18
18
import { FirebaseNamespace } from './public-types' ;
19
- import { isBrowser } from '@firebase/util' ;
19
+ import { getGlobal } from '@firebase/util' ;
20
20
import { firebase as firebaseNamespace } from './firebaseNamespace' ;
21
21
import { logger } from './logger' ;
22
22
import { registerCoreComponents } from './registerCoreComponents' ;
@@ -27,22 +27,28 @@ declare global {
27
27
}
28
28
}
29
29
30
- // Firebase Lite detection
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- if ( isBrowser ( ) && window . firebase !== undefined ) {
33
- logger . warn ( `
34
- Warning: Firebase is already defined in the global scope. Please make sure
35
- Firebase library is only loaded once.
36
- ` ) ;
37
-
38
- // eslint-disable-next-line
39
- const sdkVersion = ( window . firebase as FirebaseNamespace ) . SDK_VERSION ;
40
- if ( sdkVersion && sdkVersion . indexOf ( 'LITE' ) >= 0 ) {
30
+ try {
31
+ const globals = getGlobal ( ) ;
32
+ // Firebase Lite detection
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ if ( ( globals as any ) . firebase !== undefined ) {
41
35
logger . warn ( `
42
- Warning: You are trying to load Firebase while using Firebase Performance standalone script.
43
- You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code .
36
+ Warning: Firebase is already defined in the global scope. Please make sure
37
+ Firebase library is only loaded once .
44
38
` ) ;
39
+
40
+ // eslint-disable-next-line
41
+ const sdkVersion = ( ( globals as any ) . firebase as FirebaseNamespace )
42
+ . SDK_VERSION ;
43
+ if ( sdkVersion && sdkVersion . indexOf ( 'LITE' ) >= 0 ) {
44
+ logger . warn ( `
45
+ Warning: You are trying to load Firebase while using Firebase Performance standalone script.
46
+ You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.
47
+ ` ) ;
48
+ }
45
49
}
50
+ } catch {
51
+ // ignore errors thrown by getGlobal
46
52
}
47
53
48
54
const firebase = firebaseNamespace ;
0 commit comments