Skip to content

Commit 223f8ca

Browse files
Add ReactNative and Browser builds
1 parent b07f822 commit 223f8ca

22 files changed

+128
-44
lines changed

packages/firestore/exp/index.d.ts renamed to packages/firestore/exp-types/index.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export interface Settings {
3434
ssl?: boolean;
3535
ignoreUndefinedProperties?: boolean;
3636
cacheSizeBytes?: number;
37-
experimentalForceLongPolling?: boolean;
3837
}
3938

4039
export interface SnapshotListenOptions {
@@ -45,7 +44,9 @@ export interface SnapshotOptions {
4544
readonly serverTimestamps?: 'estimate' | 'previous' | 'none';
4645
}
4746

48-
export interface SnapshotMetadata {
47+
export class SnapshotMetadata {
48+
private constructor();
49+
4950
readonly hasPendingWrites: boolean;
5051
readonly fromCache: boolean;
5152

packages/firestore/exp/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"name": "@firebase/firestore/exp",
33
"description": "A tree-shakeable version of the Firestore SDK",
4-
"main": "../dist/exp/index.node.esm2017.js",
4+
"main": "../dist/lite/index.node.esm2017.js",
5+
"browser": "../dist/lite/index.browser.esm2017.js",
6+
"react-native": "../dist/lite/index.rn.esm2017.js",
57
"private": true
68
}

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

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

18-
import * as firestore from '../../index';
18+
import * as firestore from '../../../exp-types';
1919

2020
import { _getProvider, _removeServiceInstance } from '@firebase/app-exp';
2121
import { FirebaseApp, _FirebaseService } from '@firebase/app-types-exp';
@@ -101,7 +101,7 @@ export class Firestore extends LiteFirestore
101101
const databaseInfo = this._makeDatabaseInfo(
102102
settings.host,
103103
settings.ssl,
104-
settings.experimentalForceLongPolling
104+
/* experimentalForceLongPolling= */ false
105105
);
106106

107107
this._deferredInitialization = this._firestoreClient.start(

packages/firestore/exp/src/api/reference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
// See https://github.com/typescript-eslint/typescript-eslint/issues/363
1919
// eslint-disable-next-line @typescript-eslint/no-unused-vars
20-
import * as firestore from '../../index';
20+
import * as firestore from '../../../exp-types';
2121

2222
import { Firestore } from './database';
2323
import {

packages/firestore/exp/src/api/snapshot.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 * as firestore from '../../index';
18+
import * as firestore from '../../../exp-types';
1919

2020
import { DocumentKey } from '../../../src/model/document_key';
2121
import { Document } from '../../../src/model/document';

packages/firestore/exp/src/api/transaction.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 * as firestore from '../../index';
18+
import * as firestore from '../../../exp-types';
1919

2020
import { Transaction as LiteTransaction } from '../../../lite/src/api/transaction';
2121
import { DocumentSnapshot } from './snapshot';

packages/firestore/exp/src/api/write_batch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
// See https://github.com/typescript-eslint/typescript-eslint/issues/363
1919
// eslint-disable-next-line @typescript-eslint/no-unused-vars
20-
import * as firestore from '../../index';
20+
import * as firestore from '../../../exp-types';
2121

2222
import { cast } from '../../../lite/src/api/util';
2323
import { WriteBatch } from '../../../lite/src/api/write_batch';

packages/firestore/externs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
"node_modules/typescript/lib/lib.es2017.string.d.ts",
1515
"packages/app-types/index.d.ts",
1616
"packages/app-types/private.d.ts",
17+
"packages-exp/app-types-exp/index.d.ts",
1718
"packages/auth-interop-types/index.d.ts",
19+
"packages/firestore/exp-types/index.d.ts",
20+
"packages/firestore/lite-types/index.d.ts",
1821
"packages/firestore-types/index.d.ts",
1922
"packages/firebase/index.d.ts",
2023
"packages/component/dist/src/component.d.ts",

packages/firestore/lite/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
"name": "@firebase/firestore/lite",
33
"description": "A lite version of the Firestore SDK",
44
"main": "../dist/lite/index.node.esm2017.js",
5+
"browser": "../dist/lite/index.browser.esm2017.js",
6+
"react-native": "../dist/lite/index.rn.esm2017.js",
57
"private": true
68
}

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

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

18-
import * as firestore from '../../';
18+
import * as firestore from '../../../lite-types';
1919

2020
import { _getProvider, _removeServiceInstance } from '@firebase/app-exp';
2121
import { FirebaseApp, _FirebaseService } from '@firebase/app-types-exp';
@@ -36,7 +36,6 @@ import {
3636
import { newConnection } from '../../../src/platform/connection';
3737
import { newSerializer } from '../../../src/platform/serializer';
3838
import { cast } from './util';
39-
import { Settings } from '../../';
4039

4140
// settings() defaults:
4241
export const DEFAULT_HOST = 'firestore.googleapis.com';
@@ -81,7 +80,7 @@ export class Firestore
8180
this._settings = settings;
8281
}
8382

84-
_getSettings(): Settings {
83+
_getSettings(): firestore.Settings {
8584
if (!this._settings) {
8685
this._settings = {};
8786
}

packages/firestore/lite/src/api/field_path.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 * as firestore from '../../index';
18+
import * as firestore from '../../../lite-types';
1919

2020
import { BaseFieldPath } from '../../../src/api/field_path';
2121
import { cast } from './util';

packages/firestore/lite/src/api/field_value.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 * as firestore from '../../';
18+
import * as firestore from '../../../lite-types';
1919

2020
import { validateAtLeastNumberOfArgs } from '../../../src/util/input_validation';
2121
import {

packages/firestore/lite/src/api/reference.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 * as firestore from '../../index';
18+
import * as firestore from '../../../lite-types';
1919

2020
import { Document } from '../../../src/model/document';
2121
import { DocumentKey } from '../../../src/model/document_key';

packages/firestore/lite/src/api/snapshot.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 * as firestore from '../../index';
18+
import * as firestore from '../../../lite-types';
1919

2020
import { Firestore } from './database';
2121
import { DocumentReference, queryEqual } from './reference';

packages/firestore/lite/src/api/transaction.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 * as firestore from '../../';
18+
import * as firestore from '../../../lite-types';
1919

2020
import {
2121
parseSetData,

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

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

18-
import * as firestore from '../../index';
18+
import * as firestore from '../../../lite-types';
19+
1920
import {
2021
DeleteMutation,
2122
Mutation,

packages/firestore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"pretest:exp": "yarn build:exp",
2626
"pregendeps:lite": "yarn build:lite",
2727
"gendeps:lite": "../../scripts/exp/extract-deps.sh --types ./lite/index.d.ts --bundle ./dist/lite/index.node.esm2017.js --output ./lite/test/dependencies.json",
28-
"test:exp": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'exp/test/**/*.test.ts' --file exp/index.node.ts --config ../../config/mocharc.node.js",
28+
"test:exp": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'exp/test/**/*.test.ts' --file exp/index.ts --config ../../config/mocharc.node.js",
2929
"test": "run-s lint test:all",
3030
"test:ci": "node ../../scripts/run_tests_in_ci.js",
3131
"test:all": "run-p test:browser test:travis test:minified",
@@ -38,7 +38,7 @@
3838
"test:travis": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/firestore-test-runner.ts",
3939
"test:minified": "(cd ../../integration/firestore ; yarn test)",
4040
"pretest:lite": "yarn build:lite",
41-
"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",
41+
"test:lite": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'lite/test/**/*.test.ts' --file lite/index.ts --config ../../config/mocharc.node.js",
4242
"prepare": "yarn build:release"
4343
},
4444
"main": "dist/index.node.cjs.js",

packages/firestore/rollup.config.exp.js

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ import alias from '@rollup/plugin-alias';
2020
import typescriptPlugin from 'rollup-plugin-typescript2';
2121
import typescript from 'typescript';
2222
import path from 'path';
23+
import { terser } from 'rollup-plugin-terser';
2324

24-
import { generateAliasConfig, resolveNodeExterns } from './rollup.shared';
25+
import {
26+
firestoreTransformers,
27+
generateAliasConfig,
28+
manglePrivatePropertiesOptions,
29+
resolveBrowserExterns,
30+
resolveNodeExterns
31+
} from './rollup.shared';
2532

2633
import pkg from './exp/package.json';
2734

28-
const defaultPlugins = [
29-
alias(generateAliasConfig('node')),
35+
const plugins = [
3036
typescriptPlugin({
3137
typescript,
3238
tsconfigOverride: {
@@ -39,19 +45,52 @@ const defaultPlugins = [
3945
json({ preferConst: true })
4046
];
4147

42-
const nodeBuilds = [
48+
const minifiedPlugins = [
49+
typescriptPlugin({
50+
typescript,
51+
tsconfigOverride: {
52+
compilerOptions: {
53+
target: 'es2017'
54+
}
55+
},
56+
clean: true,
57+
transformers: firestoreTransformers
58+
}),
59+
json({ preferConst: true }),
60+
terser(manglePrivatePropertiesOptions)
61+
];
62+
63+
const allBuilds = [
64+
// Node build
4365
{
44-
input: './exp/index.node.ts',
66+
input: './exp/index.ts',
4567
output: {
4668
file: path.resolve('./exp', pkg.main),
4769
format: 'es'
4870
},
49-
plugins: defaultPlugins,
50-
external: resolveNodeExterns,
51-
treeshake: {
52-
tryCatchDeoptimization: false
53-
}
71+
plugins: [alias(generateAliasConfig('node')), ...plugins],
72+
external: resolveNodeExterns
73+
},
74+
// Browser build
75+
{
76+
input: './exp/index.ts',
77+
output: {
78+
file: path.resolve('./exp', pkg.browser),
79+
format: 'es'
80+
},
81+
plugins: [alias(generateAliasConfig('browser')), ...minifiedPlugins],
82+
external: resolveBrowserExterns
83+
},
84+
// RN build
85+
{
86+
input: './exp/index.ts',
87+
output: {
88+
file: path.resolve('./exp', pkg['react-native']),
89+
format: 'es'
90+
},
91+
plugins: [alias(generateAliasConfig('rn')), ...minifiedPlugins],
92+
external: resolveBrowserExterns
5493
}
5594
];
5695

57-
export default [...nodeBuilds];
96+
export default allBuilds;

packages/firestore/rollup.config.lite.js

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ import json from 'rollup-plugin-json';
1919
import alias from '@rollup/plugin-alias';
2020
import typescriptPlugin from 'rollup-plugin-typescript2';
2121
import typescript from 'typescript';
22+
import { terser } from 'rollup-plugin-terser';
2223

23-
import { resolveNodeExterns, generateAliasConfig } from './rollup.shared';
24+
import {
25+
resolveNodeExterns,
26+
generateAliasConfig,
27+
resolveBrowserExterns,
28+
firestoreTransformers,
29+
manglePrivatePropertiesOptions
30+
} from './rollup.shared';
2431

2532
import pkg from './lite/package.json';
2633
import path from 'path';
2734

28-
const defaultPlugins = [
29-
alias(generateAliasConfig('node')),
35+
const plugins = [
3036
typescriptPlugin({
3137
typescript,
3238
tsconfigOverride: {
@@ -39,21 +45,52 @@ const defaultPlugins = [
3945
json({ preferConst: true })
4046
];
4147

42-
const nodeBuilds = [
48+
const minifiedPlugins = [
49+
typescriptPlugin({
50+
typescript,
51+
tsconfigOverride: {
52+
compilerOptions: {
53+
target: 'es2017'
54+
}
55+
},
56+
clean: true,
57+
transformers: firestoreTransformers
58+
}),
59+
json({ preferConst: true }),
60+
terser(manglePrivatePropertiesOptions)
61+
];
62+
63+
const allBuilds = [
64+
// Node build
4365
{
44-
input: 'lite/index.node.ts',
66+
input: './lite/index.ts',
4567
output: {
4668
file: path.resolve('./lite', pkg.main),
4769
format: 'es'
4870
},
49-
plugins: defaultPlugins,
50-
external: resolveNodeExterns,
51-
treeshake: {
52-
tryCatchDeoptimization: false
53-
}
71+
plugins: [alias(generateAliasConfig('node')), ...plugins],
72+
external: resolveNodeExterns
73+
},
74+
// Browser build
75+
{
76+
input: './lite/index.ts',
77+
output: {
78+
file: path.resolve('./lite', pkg.browser),
79+
format: 'es'
80+
},
81+
plugins: [alias(generateAliasConfig('browser')), ...minifiedPlugins],
82+
external: resolveBrowserExterns
83+
},
84+
// RN build
85+
{
86+
input: './lite/index.ts',
87+
output: {
88+
file: path.resolve('./lite', pkg['react-native']),
89+
format: 'es'
90+
},
91+
plugins: [alias(generateAliasConfig('rn')), ...minifiedPlugins],
92+
external: resolveBrowserExterns
5493
}
5594
];
5695

57-
// TODO(firestorelite): Add browser builds
58-
59-
export default [...nodeBuilds];
96+
export default allBuilds;

0 commit comments

Comments
 (0)