File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -111,5 +111,8 @@ function initFirestore(app: FirebaseApp): Firestore {
111
111
'to use Cloud Firestore API.' ,
112
112
} ) ;
113
113
}
114
- return new Firestore ( options ) ;
114
+
115
+ // Lazy-load the Firestore implementation here, which in turns loads gRPC.
116
+ let firestoreDatabase = require ( '@google-cloud/firestore' ) ;
117
+ return new firestoreDatabase ( options ) ;
115
118
}
Original file line number Diff line number Diff line change @@ -97,6 +97,34 @@ utils.assert(
97
97
'admin.messaging(app).app' ,
98
98
'App instances do not match.'
99
99
) ;
100
+ utils . assert (
101
+ _ . isEqual ( admin . storage ( nonNullApp ) . app , nonNullApp ) ,
102
+ 'admin.storage(app).app' ,
103
+ 'App instances do not match.'
104
+ ) ;
105
+
106
+ // Firestore should not be loaded yet.
107
+ var gcloud = require . cache [ require . resolve ( '@google-cloud/firestore' ) ] ;
108
+ utils . assert (
109
+ typeof gcloud === 'undefined' ,
110
+ 'require(firebase-admin)' ,
111
+ 'Firestore module already loaded'
112
+ ) ;
113
+
114
+ // Calling admin.firestore should load Firestore
115
+ const firestoreNamespace = admin . firestore ;
116
+ utils . assert (
117
+ typeof firestoreNamespace !== 'undefined' ,
118
+ 'admin.firestore' ,
119
+ 'Firestore namespace could not be loaded.'
120
+ ) ;
121
+
122
+ gcloud = require . cache [ require . resolve ( '@google-cloud/firestore' ) ] ;
123
+ utils . assert (
124
+ typeof gcloud !== 'undefined' ,
125
+ 'admin.firestore' ,
126
+ 'Firestore module not loaded'
127
+ ) ;
100
128
101
129
/**
102
130
* Prompts the developer whether the Database rules should be
You can’t perform that action at this time.
0 commit comments