Skip to content

Commit 30bfc3f

Browse files
Review
1 parent da82b5d commit 30bfc3f

File tree

7 files changed

+27
-20
lines changed

7 files changed

+27
-20
lines changed

packages/firestore/lite/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { FirebaseApp } from '@firebase/app-types';
18+
import { FirebaseApp } from '@firebase/app-types-exp';
1919

2020
/* eslint-disable @typescript-eslint/no-explicit-any */
2121

packages/firestore/lite/index.node.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18-
import firebase from '@firebase/app';
19-
import { FirebaseNamespace } from '@firebase/app-types';
18+
import { registerVersion } from '@firebase/app-exp';
2019
import {
2120
Firestore,
2221
initializeFirestore,
2322
getFirestore
2423
} from './src/api/database';
2524
import { version } from '../package.json';
2625
import { Component, ComponentType } from '@firebase/component';
27-
import { _FirebaseNamespace } from '@firebase/app-types/private';
26+
import { _registerComponent } from '@firebase/app-exp';
2827
import { makeConstructorPrivate } from '../src/util/api';
2928

3029
export const PublicFirestore = makeConstructorPrivate(
@@ -38,12 +37,12 @@ const firestoreNamespace = {
3837
getFirestore
3938
};
4039

41-
export function registerFirestore(instance: FirebaseNamespace): void {
42-
(instance as _FirebaseNamespace).INTERNAL.registerComponent(
40+
export function registerFirestore(): void {
41+
_registerComponent(
4342
new Component(
4443
'firestore/lite',
4544
container => {
46-
const app = container.getProvider('app').getImmediate()!;
45+
const app = container.getProvider('app-exp').getImmediate()!;
4746
return ((app, auth) => new Firestore(app, auth))(
4847
app,
4948
container.getProvider('auth-internal')
@@ -52,7 +51,7 @@ export function registerFirestore(instance: FirebaseNamespace): void {
5251
ComponentType.PUBLIC
5352
).setServiceProps({ ...firestoreNamespace })
5453
);
55-
instance.registerVersion('@firebase/firestore/lite', version, 'node');
54+
registerVersion('firestore-lite', version, 'node');
5655
}
5756

58-
registerFirestore(firebase);
57+
registerFirestore();

packages/firestore/lite/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "@firebase/firestore/lite",
3+
"description": "A lite version of the Firestore SDK",
4+
"main": "../dist/list/index.node.cjs.js"
5+
}

packages/firestore/lite/src/api/database.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google LLC
3+
* Copyright 2020 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -18,9 +18,8 @@
1818
import * as firestore from '../../';
1919

2020
import { _getProvider } from '@firebase/app-exp';
21+
import { FirebaseApp } from '@firebase/app-types-exp';
2122
import { Provider } from '@firebase/component';
22-
import { FirebaseApp } from '@firebase/app-types';
23-
import { FirebaseService } from '@firebase/app-types/private';
2423

2524
import { Code, FirestoreError } from '../../../src/util/error';
2625
import { DatabaseId } from '../../../src/core/database_info';
@@ -30,10 +29,12 @@ import {
3029
FirebaseCredentialsProvider
3130
} from '../../../src/api/credentials';
3231

32+
// TODO(firestorelite): Depend on FirebaseService once #3112 is merged
33+
3334
/**
3435
* The root reference to the Firestore Lite database.
3536
*/
36-
export class Firestore implements firestore.FirebaseFirestore, FirebaseService {
37+
export class Firestore implements firestore.FirebaseFirestore {
3738
readonly _databaseId: DatabaseId;
3839
private readonly _firebaseApp: FirebaseApp;
3940
private readonly _credentials: CredentialsProvider;

packages/firestore/lite/test/integration.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717

1818
import { expect } from 'chai';
1919

20-
import firebase from '../../test/integration/util/firebase_export';
20+
import { initializeApp } from '@firebase/app-exp';
2121
import { getFirestore, initializeFirestore } from '../src/api/database';
2222

2323
describe('Firestore', () => {
2424
it('can provide setting', () => {
25-
const app = firebase.initializeApp(
25+
const app = initializeApp(
2626
{ apiKey: 'fake-api-key', projectId: 'test-project' },
2727
'test-app-initializeFirestore'
2828
);
2929
initializeFirestore(app, { host: 'localhost', ssl: false });
3030
});
3131

3232
it('returns same instance', () => {
33-
const app = firebase.initializeApp(
33+
const app = initializeApp(
3434
{ apiKey: 'fake-api-key', projectId: 'test-project' },
3535
'test-app-getFirestore'
3636
);

packages/firestore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"test:lite": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'lite/test/**/*.test.ts' --file lite/index.node.ts --config ../../config/mocharc.node.js",
3838
"prepare": "yarn build"
3939
},
40-
"lite": "dist/lite/index.node.cjs.js",
4140
"main": "dist/index.node.cjs.js",
4241
"main-esm2017": "dist/index.node.esm2017.js",
4342
"browser": "dist/index.cjs.js",
@@ -61,7 +60,8 @@
6160
},
6261
"peerDependencies": {
6362
"@firebase/app": "0.x",
64-
"@firebase/app-types": "0.x"
63+
"@firebase/app-types": "0.x",
64+
"@firebase/app-types-ext": "0.x"
6565
},
6666
"devDependencies": {
6767
"@types/json-stable-stringify": "1.0.32",

packages/firestore/rollup.config.lite.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import typescript from 'typescript';
2121

2222
import { resolveNodeExterns } from './rollup.shared';
2323

24-
import pkg from './package.json';
24+
import pkg from './lite/package.json';
2525

2626
const defaultPlugins = [
2727
typescriptPlugin({
@@ -40,7 +40,7 @@ const nodeBuilds = [
4040
{
4141
input: 'lite/index.node.ts',
4242
output: {
43-
file: pkg.lite,
43+
file: pkg.main,
4444
format: 'es'
4545
},
4646
plugins: defaultPlugins,
@@ -51,4 +51,6 @@ const nodeBuilds = [
5151
}
5252
];
5353

54+
// TODO(firestorelite): Add browser builds
55+
5456
export default [...nodeBuilds];

0 commit comments

Comments
 (0)