Skip to content

Add ReactNative and Browser builds (Lite/Exp) #3400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export interface Settings {
ssl?: boolean;
ignoreUndefinedProperties?: boolean;
cacheSizeBytes?: number;
experimentalForceLongPolling?: boolean;
}

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

export interface SnapshotMetadata {
export class SnapshotMetadata {
private constructor();

readonly hasPendingWrites: boolean;
readonly fromCache: boolean;

Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion packages/firestore/exp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "@firebase/firestore/exp",
"description": "A tree-shakeable version of the Firestore SDK",
"main": "../dist/exp/index.node.esm2017.js",
"main": "../dist/exp/index.node.umd.js",
"browser": "../dist/exp/index.browser.esm2017.js",
"react-native": "../dist/exp/index.rn.esm2017.js",
"private": true
}
4 changes: 2 additions & 2 deletions packages/firestore/exp/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

import { _getProvider, _removeServiceInstance } from '@firebase/app-exp';
import { FirebaseApp, _FirebaseService } from '@firebase/app-types-exp';
Expand Down Expand Up @@ -101,7 +101,7 @@ export class Firestore extends LiteFirestore
const databaseInfo = this._makeDatabaseInfo(
settings.host,
settings.ssl,
settings.experimentalForceLongPolling
/* experimentalForceLongPolling= */ false
);

this._deferredInitialization = this._firestoreClient.start(
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/exp/src/api/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

import { Firestore } from './database';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/exp/src/api/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

import { DocumentKey } from '../../../src/model/document_key';
import { Document } from '../../../src/model/document';
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/exp/src/api/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

import { Transaction as LiteTransaction } from '../../../lite/src/api/transaction';
import { DocumentSnapshot } from './snapshot';
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/exp/src/api/write_batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

import { cast } from '../../../lite/src/api/util';
import { WriteBatch } from '../../../lite/src/api/write_batch';
Expand Down
6 changes: 3 additions & 3 deletions packages/firestore/exp/test/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { FirebaseApp as FirebaseAppLegacy } from '@firebase/app-types';
import { FirebaseApp as FirebaseAppExp } from '@firebase/app-types-exp';
import { deleteApp } from '@firebase/app-exp';
import * as legacy from '@firebase/firestore-types';
import * as exp from '../';
import * as exp from '../../exp-types';

import {
addDoc,
Expand Down Expand Up @@ -58,12 +58,12 @@ import {
updateDoc,
waitForPendingWrites,
writeBatch
} from '../../exp/index.node';
} from '../../exp/index';
import { UntypedFirestoreDataConverter } from '../../src/api/user_data_reader';
import { isPartialObserver, PartialObserver } from '../../src/api/observer';
import { isPlainObject } from '../../src/util/input_validation';

export { GeoPoint, Blob, Timestamp } from '../index.node';
export { GeoPoint, Blob, Timestamp } from '../index';

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

Expand Down
3 changes: 3 additions & 0 deletions packages/firestore/externs.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"node_modules/typescript/lib/lib.es2017.string.d.ts",
"packages/app-types/index.d.ts",
"packages/app-types/private.d.ts",
"packages-exp/app-types-exp/index.d.ts",
"packages/auth-interop-types/index.d.ts",
"packages/firestore/exp-types/index.d.ts",
"packages/firestore/lite-types/index.d.ts",
"packages/firestore-types/index.d.ts",
"packages/firebase/index.d.ts",
"packages/component/dist/src/component.d.ts",
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion packages/firestore/lite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "@firebase/firestore/lite",
"description": "A lite version of the Firestore SDK",
"main": "../dist/lite/index.node.esm2017.js",
"main": "../dist/lite/index.node.umd.js",
"browser": "../dist/lite/index.browser.esm2017.js",
"react-native": "../dist/lite/index.rn.esm2017.js",
"private": true
}
5 changes: 2 additions & 3 deletions packages/firestore/lite/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

import { _getProvider, _removeServiceInstance } from '@firebase/app-exp';
import { FirebaseApp, _FirebaseService } from '@firebase/app-types-exp';
Expand All @@ -36,7 +36,6 @@ import {
import { newConnection } from '../../../src/platform/connection';
import { newSerializer } from '../../../src/platform/serializer';
import { cast } from './util';
import { Settings } from '../../';

// settings() defaults:
export const DEFAULT_HOST = 'firestore.googleapis.com';
Expand Down Expand Up @@ -81,7 +80,7 @@ export class Firestore
this._settings = settings;
}

_getSettings(): Settings {
_getSettings(): firestore.Settings {
if (!this._settings) {
this._settings = {};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/lite/src/api/field_path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import * as firestore from '../../index';
import * as firestore from '../../../lite-types';

import { BaseFieldPath } from '../../../src/api/field_path';
import { cast } from './util';
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/lite/src/api/field_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

import { validateAtLeastNumberOfArgs } from '../../../src/util/input_validation';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/lite/src/api/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import * as firestore from '../../index';
import * as firestore from '../../../lite-types';

import { Document } from '../../../src/model/document';
import { DocumentKey } from '../../../src/model/document_key';
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/lite/src/api/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import * as firestore from '../../index';
import * as firestore from '../../../lite-types';

import { Firestore } from './database';
import { DocumentReference, queryEqual } from './reference';
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/lite/src/api/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

import {
parseSetData,
Expand Down
3 changes: 2 additions & 1 deletion packages/firestore/lite/src/api/write_batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import * as firestore from '../../index';
import * as firestore from '../../../lite-types';

import {
DeleteMutation,
Mutation,
Expand Down
6 changes: 3 additions & 3 deletions packages/firestore/lite/test/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import * as legacy from '@firebase/firestore-types';
import * as lite from '../';
import * as lite from '../../lite-types';

import {
addDoc,
Expand All @@ -43,11 +43,11 @@ import {
updateDoc,
writeBatch,
initializeFirestore
} from '../../lite/index.node';
} from '../../lite/index';
import { UntypedFirestoreDataConverter } from '../../src/api/user_data_reader';
import { isPlainObject } from '../../src/util/input_validation';

export { GeoPoint, Blob, Timestamp } from '../index.node';
export { GeoPoint, Blob, Timestamp } from '../index';

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

Expand Down
6 changes: 3 additions & 3 deletions packages/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"gendeps:exp": "../../scripts/exp/extract-deps.sh --types ./exp/index.d.ts --bundle ./dist/exp/index.node.esm2017.js --output ./exp/test/deps/dependencies.json",
"pregendeps:lite": "yarn build:lite",
"gendeps:lite": "../../scripts/exp/extract-deps.sh --types ./lite/index.d.ts --bundle ./dist/lite/index.node.esm2017.js --output ./lite/test/dependencies.json",
"test:exp": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/integration/api/*.test.ts' --file exp/index.node.ts --config ../../config/mocharc.node.js",
"test:exp:persistence": "USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/integration/api/*.test.ts' --require ts-node/register --require exp/index.node.ts --require test/util/node_persistence.ts --config ../../config/mocharc.node.js",
"test:exp": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/integration/api/*.test.ts' --file exp/index.ts --config ../../config/mocharc.node.js",
"test:exp:persistence": "USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/integration/api/*.test.ts' --require ts-node/register --require exp/index.ts --require test/util/node_persistence.ts --config ../../config/mocharc.node.js",
"test": "run-s lint test:all",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:all": "run-p test:browser test:travis test:minified test:exp",
Expand All @@ -38,7 +38,7 @@
"test:travis": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/firestore-test-runner.ts",
"test:minified": "(cd ../../integration/firestore ; yarn test)",
"pretest:lite": "yarn build:lite",
"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",
"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",
"prepare": "yarn build:release"
},
"main": "dist/index.node.cjs.js",
Expand Down
64 changes: 52 additions & 12 deletions packages/firestore/rollup.config.exp.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,78 @@ import alias from '@rollup/plugin-alias';
import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';
import path from 'path';
import { terser } from 'rollup-plugin-terser';

import { generateAliasConfig, resolveNodeExterns } from './rollup.shared';
import {
firestoreTransformers,
generateAliasConfig,
manglePrivatePropertiesOptions,
resolveBrowserExterns,
resolveNodeExterns
} from './rollup.shared';

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

const defaultPlugins = [
alias(generateAliasConfig('node')),
const nodePlugins = [
typescriptPlugin({
typescript,
tsconfigOverride: {
compilerOptions: {
target: 'es2017'
target: 'es5'
}
},
clean: true
}),
json({ preferConst: true })
];

const nodeBuilds = [
const browserPlugins = [
typescriptPlugin({
typescript,
tsconfigOverride: {
compilerOptions: {
target: 'es2017'
}
},
clean: true,
transformers: firestoreTransformers
}),
json({ preferConst: true }),
terser(manglePrivatePropertiesOptions)
];

const allBuilds = [
// Node build
{
input: './exp/index.node.ts',
input: './exp/index.ts',
output: {
file: path.resolve('./exp', pkg.main),
format: 'umd',
name: 'firebase.firestore'
},
plugins: [alias(generateAliasConfig('node')), ...nodePlugins],
external: resolveNodeExterns
},
// Browser build
{
input: './exp/index.ts',
output: {
file: path.resolve('./exp', pkg.browser),
format: 'es'
},
plugins: [alias(generateAliasConfig('browser')), ...browserPlugins],
external: resolveBrowserExterns
},
// RN build
{
input: './exp/index.ts',
output: {
file: path.resolve('./exp', pkg['react-native']),
format: 'es'
},
plugins: defaultPlugins,
external: resolveNodeExterns,
treeshake: {
tryCatchDeoptimization: false
}
plugins: [alias(generateAliasConfig('rn')), ...browserPlugins],
external: resolveBrowserExterns
}
];

export default [...nodeBuilds];
export default allBuilds;
Loading