Skip to content

Firestore bundle build #4090

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 6 commits into from
Nov 20, 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
13 changes: 1 addition & 12 deletions integration/firestore/firebase_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,5 @@ const Timestamp = firebase.firestore.Timestamp;
const GeoPoint = firebase.firestore.GeoPoint;
const FieldValue = firebase.firestore.FieldValue;
const Blob = firebase.firestore.Blob;
const loadBundle = firebase.firestore.loadBundle;
const namedQuery = firebase.firestore.namedQuery;

export {
Firestore,
FieldValue,
FieldPath,
Timestamp,
Blob,
GeoPoint,
loadBundle,
namedQuery
};
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };
13 changes: 1 addition & 12 deletions integration/firestore/firebase_export_memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,5 @@ const Timestamp = firebase.firestore.Timestamp;
const GeoPoint = firebase.firestore.GeoPoint;
const FieldValue = firebase.firestore.FieldValue;
const Blob = firebase.firestore.Blob;
const loadBundle = firebase.firestore.loadBundle;
const namedQuery = firebase.firestore.namedQuery;

export {
Firestore,
FieldValue,
FieldPath,
Timestamp,
Blob,
GeoPoint,
loadBundle,
namedQuery
};
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };
10 changes: 10 additions & 0 deletions packages/firestore/bundle/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@firebase/firestore/bundle",
"description": "Firestore bundle",
"main": "../dist/node-cjs/bundle.js",
"main-esm2017": "../dist/node-esm2017/bundle.js",
"react-native": "../dist/rn/bundle.js",
"browser": "../dist/esm5/bundle.js",
"module": "../dist/esm5/bundle.js",
"esm2017": "../dist/esm2017/bundle.js"
}
6 changes: 2 additions & 4 deletions packages/firestore/exp/test/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ import {
DocumentSnapshot,
QuerySnapshot,
wrapObserver,
extractSnapshotOptions,
loadBundle,
namedQuery
extractSnapshotOptions
} from '../../src/api/database';

export { GeoPoint, Timestamp } from '../index';
export { loadBundle, namedQuery };
export { loadBundle, namedQuery } from '../../src/api/bundle';

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

Expand Down
14 changes: 8 additions & 6 deletions packages/firestore/index.bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,25 @@
* limitations under the License.
*/

import * as firestore from '@firebase/firestore-types';
import { loadBundle, namedQuery } from './src/api/database';
import { Firestore } from './src/api/database';
import { loadBundle, namedQuery } from './src/api/bundle';

/**
* Registers the memory-only Firestore build with the components framework.
*/
export function registerBundle(
instance: typeof firestore.FirebaseFirestore
): void {
export function registerBundle(instance: typeof Firestore): void {
instance.prototype.loadBundle = function (
data: ArrayBuffer | ReadableStream<Uint8Array> | string
) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return loadBundle(this as any, data);
};
instance.prototype.namedQuery = function (queryName: string) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return namedQuery(this as any, queryName);
};

//TODO: add loadBundle and namedQuery to the firestore namespace
}

registerBundle(firestore.FirebaseFirestore);
registerBundle(Firestore);
12 changes: 6 additions & 6 deletions packages/firestore/memory/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@firebase/firestore/memory",
"description": "A memory-only build of the Cloud Firestore JS SDK.",
"main": "../dist/index.memory.node.cjs.js",
"main-esm2017": "../dist/index.memory.node.esm2017.js",
"react-native": "../dist/index.memory.rn.esm2017.js",
"browser": "../dist/index.memory.esm.js",
"module": "../dist/index.memory.esm.js",
"esm2017": "../dist/index.memory.esm2017.js",
"main": "../dist/node-cjs/memory.js",
"main-esm2017": "../dist/node-esm2017/memory.js",
"react-native": "../dist/rn/memory.js",
"browser": "../dist/esm5/memory.js",
"module": "../dist/esm5/memory.js",
"esm2017": "../dist/esm2017/memory.js",
"typings": "../dist/index.d.ts"
}
23 changes: 11 additions & 12 deletions packages/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"scripts": {
"bundle": "rollup -c",
"build": "run-p 'bundle rollup.config.browser.js' 'bundle rollup.config.browser.memory.js' 'bundle rollup.config.node.js' 'bundle rollup.config.node.memory.js' 'bundle rollup.config.rn.js' 'bundle rollup.config.rn.memory.js' build:lite build:exp",
"build": "run-p 'bundle rollup.config.browser.js' 'bundle rollup.config.node.js' 'bundle rollup.config.rn.js' build:lite build:exp",
"build:scripts": "tsc -moduleResolution node --module commonjs scripts/*.ts && ls scripts/*.js | xargs -I % sh -c 'terser % -o %'",
"build:release": "run-p 'bundle rollup.config.browser.js' 'bundle rollup.config.browser.memory.js' 'bundle rollup.config.node.js' 'bundle rollup.config.node.memory.js' 'bundle rollup.config.rn.js' 'bundle rollup.config.rn.memory.js'",
"build:release": "run-p 'bundle rollup.config.browser.js' 'bundle rollup.config.node.js' 'bundle rollup.config.rn.js'",
"build:deps": "lerna run --scope @firebase/firestore --include-dependencies build",
"build:console": "node tools/console.build.js",
"build:exp": "rollup -c rollup.config.exp.js",
Expand Down Expand Up @@ -52,18 +52,17 @@
"predoc": "node ../../scripts/exp/remove-exp.js temp",
"doc": "api-documenter markdown --input temp --output docs"
},
"main": "dist/index.node.cjs.js",
"main-esm2017": "dist/index.node.esm2017.js",
"react-native": "dist/index.rn.esm2017.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"esm2017": "dist/index.esm2017.js",
"bundle": "dist/index.bundle.js",
"bundleModule": "dist/index.bundle.module.js",
"main": "dist/node-cjs/index.js",
"main-esm2017": "dist/node-esm2017/index.js",
"react-native": "dist/rn/index.js",
"browser": "dist/esm5/index.js",
"module": "dist/esm5/index.js",
"esm2017": "dist/esm2017/index.js",
"license": "Apache-2.0",
"files": [
"dist",
"memory/package.json"
"memory/package.json",
"bundle/package.json"
],
"dependencies": {
"@firebase/component": "0.1.21",
Expand All @@ -87,7 +86,7 @@
"json-stable-stringify": "1.0.1",
"protobufjs": "6.10.1",
"rollup": "2.33.1",
"rollup-plugin-copy-assets": "1.1.0",
"rollup-plugin-copy-assets": "2.0.3",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "9.0.0",
"rollup-plugin-replace": "2.2.0",
Expand Down
23 changes: 19 additions & 4 deletions packages/firestore/rollup.config.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@
*/

import pkg from './package.json';
import bundlePkg from './bundle/package.json';
import memoryPkg from './memory/package.json';
import path from 'path';

const util = require('./rollup.shared');

export default [
{
input: 'index.ts',
input: {
index: 'index.ts',
memory: 'index.memory.ts',
bundle: 'index.bundle.ts'
},
output: {
file: pkg.esm2017,
dir: 'dist/esm2017',
format: 'es',
sourcemap: true
},
Expand All @@ -34,8 +41,16 @@ export default [
}
},
{
input: pkg.esm2017,
output: { file: pkg.module, format: 'es', sourcemap: true },
input: {
index: pkg.esm2017,
memory: path.resolve('./memory', memoryPkg.esm2017),
bundle: path.resolve('./bundle', bundlePkg.esm2017)
},
output: {
dir: 'dist/esm5',
format: 'es',
sourcemap: true
},
plugins: util.es2017ToEs5Plugins(/* mangled= */ true),
external: util.resolveBrowserExterns,
treeshake: {
Expand Down
50 changes: 0 additions & 50 deletions packages/firestore/rollup.config.browser.memory.js

This file was deleted.

45 changes: 0 additions & 45 deletions packages/firestore/rollup.config.bundle.js

This file was deleted.

32 changes: 24 additions & 8 deletions packages/firestore/rollup.config.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,31 @@
import replace from 'rollup-plugin-replace';
import copy from 'rollup-plugin-copy-assets';
import pkg from './package.json';
import bundlePkg from './bundle/package.json';
import memoryPkg from './memory/package.json';
import path from 'path';

const util = require('./rollup.shared');

export default [
{
input: 'index.node.ts',
input: {
index: 'index.node.ts',
memory: 'index.node.memory.ts',
bundle: 'index.bundle.ts'
},
output: {
file: pkg['main-esm2017'],
dir: 'dist/node-esm2017',
format: 'es',
sourcemap: true
},
plugins: [
...util.es2017Plugins('node'),
// Needed as we also use the *.proto files
copy({
assets: ['./src/protos']
}),
replace({
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('src/protos')
}),
copy({
assets: ['./src/protos']
})
],
external: util.resolveNodeExterns,
Expand All @@ -45,8 +51,18 @@ export default [
}
},
{
input: pkg['main-esm2017'],
output: [{ file: pkg.main, format: 'cjs', sourcemap: true }],
input: {
index: pkg['main-esm2017'],
memory: path.resolve('./memory', memoryPkg['main-esm2017']),
bundle: path.resolve('./bundle', bundlePkg['main-esm2017'])
},
output: [
{
dir: 'dist/node-cjs',
format: 'cjs',
sourcemap: true
}
],
plugins: util.es2017ToEs5Plugins(),
external: util.resolveNodeExterns,
treeshake: {
Expand Down
Loading