Skip to content

Commit 5502615

Browse files
De-dup module registration (#2650)
This simplifies adding a new Memory-only Firestore build
1 parent d2b37c1 commit 5502615

File tree

3 files changed

+46
-54
lines changed

3 files changed

+46
-54
lines changed

packages/firestore/index.node.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* limitations under the License.
1616
*/
1717
import firebase from '@firebase/app';
18-
import * as types from '@firebase/firestore-types';
1918
import { configureForFirebase } from './src/platform/config';
19+
import './register-module';
2020
import './src/platform_node/node_init';
2121
import { FirebaseNamespace } from '@firebase/app-types';
2222

@@ -28,29 +28,3 @@ export function registerFirestore(instance: FirebaseNamespace): void {
2828
}
2929

3030
registerFirestore(firebase);
31-
32-
declare module '@firebase/app-types' {
33-
interface FirebaseNamespace {
34-
firestore?: {
35-
(app?: FirebaseApp): types.FirebaseFirestore;
36-
Blob: typeof types.Blob;
37-
CollectionReference: typeof types.CollectionReference;
38-
DocumentReference: typeof types.DocumentReference;
39-
DocumentSnapshot: typeof types.DocumentSnapshot;
40-
FieldPath: typeof types.FieldPath;
41-
FieldValue: typeof types.FieldValue;
42-
Firestore: typeof types.FirebaseFirestore;
43-
GeoPoint: typeof types.GeoPoint;
44-
Query: typeof types.Query;
45-
QueryDocumentSnapshot: typeof types.QueryDocumentSnapshot;
46-
QuerySnapshot: typeof types.QuerySnapshot;
47-
Timestamp: typeof types.Timestamp;
48-
Transaction: typeof types.Transaction;
49-
WriteBatch: typeof types.WriteBatch;
50-
setLogLevel: typeof types.setLogLevel;
51-
};
52-
}
53-
interface FirebaseApp {
54-
firestore?(): types.FirebaseFirestore;
55-
}
56-
}

packages/firestore/index.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
import firebase from '@firebase/app';
1919
import { configureForFirebase } from './src/platform/config';
20+
import './register-module';
2021
import './src/platform_browser/browser_init';
2122

22-
import * as types from '@firebase/firestore-types';
2323
import { FirebaseNamespace } from '@firebase/app-types';
2424

2525
import { name, version } from './package.json';
@@ -30,29 +30,3 @@ export function registerFirestore(instance: FirebaseNamespace): void {
3030
}
3131

3232
registerFirestore(firebase);
33-
34-
declare module '@firebase/app-types' {
35-
interface FirebaseNamespace {
36-
firestore?: {
37-
(app?: FirebaseApp): types.FirebaseFirestore;
38-
Blob: typeof types.Blob;
39-
CollectionReference: typeof types.CollectionReference;
40-
DocumentReference: typeof types.DocumentReference;
41-
DocumentSnapshot: typeof types.DocumentSnapshot;
42-
FieldPath: typeof types.FieldPath;
43-
FieldValue: typeof types.FieldValue;
44-
Firestore: typeof types.FirebaseFirestore;
45-
GeoPoint: typeof types.GeoPoint;
46-
Query: typeof types.Query;
47-
QueryDocumentSnapshot: typeof types.QueryDocumentSnapshot;
48-
QuerySnapshot: typeof types.QuerySnapshot;
49-
Timestamp: typeof types.Timestamp;
50-
Transaction: typeof types.Transaction;
51-
WriteBatch: typeof types.WriteBatch;
52-
setLogLevel: typeof types.setLogLevel;
53-
};
54-
}
55-
interface FirebaseApp {
56-
firestore?(): types.FirebaseFirestore;
57-
}
58-
}

packages/firestore/register-module.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import * as types from '@firebase/firestore-types';
19+
20+
declare module '@firebase/app-types' {
21+
interface FirebaseNamespace {
22+
firestore?: {
23+
(app?: FirebaseApp): types.FirebaseFirestore;
24+
Blob: typeof types.Blob;
25+
CollectionReference: typeof types.CollectionReference;
26+
DocumentReference: typeof types.DocumentReference;
27+
DocumentSnapshot: typeof types.DocumentSnapshot;
28+
FieldPath: typeof types.FieldPath;
29+
FieldValue: typeof types.FieldValue;
30+
Firestore: typeof types.FirebaseFirestore;
31+
GeoPoint: typeof types.GeoPoint;
32+
Query: typeof types.Query;
33+
QueryDocumentSnapshot: typeof types.QueryDocumentSnapshot;
34+
QuerySnapshot: typeof types.QuerySnapshot;
35+
Timestamp: typeof types.Timestamp;
36+
Transaction: typeof types.Transaction;
37+
WriteBatch: typeof types.WriteBatch;
38+
setLogLevel: typeof types.setLogLevel;
39+
};
40+
}
41+
interface FirebaseApp {
42+
firestore?(): types.FirebaseFirestore;
43+
}
44+
}

0 commit comments

Comments
 (0)