Skip to content

Commit 01fd8d5

Browse files
committed
bundle to share code
1 parent 8dbf020 commit 01fd8d5

20 files changed

+520
-596
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@firebase/firestore/bundle",
3+
"description": "Firestore bundle",
4+
"main": "../dist/node-cjs/bundle.js",
5+
"main-esm2017": "../dist/node-esm2017/bundle.js",
6+
"react-native": "../dist/index.memory.rn.esm2017.js",
7+
"browser": "../dist/esm5/bundle.js",
8+
"module": "../dist/esm5/bundle.js",
9+
"esm2017": "../dist/esm2017/bundle.js"
10+
}

packages/firestore/index.bundle.ts

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

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

2121
/**
2222
* Registers the memory-only Firestore build with the components framework.
2323
*/
24-
export function registerBundle(
25-
instance: typeof firestore.FirebaseFirestore
26-
): void {
24+
export function registerBundle(instance: typeof Firestore): void {
2725
instance.prototype.loadBundle = function (
2826
data: ArrayBuffer | ReadableStream<Uint8Array> | string
2927
) {
@@ -32,6 +30,8 @@ export function registerBundle(
3230
instance.prototype.namedQuery = function (queryName: string) {
3331
return namedQuery(this as any, queryName);
3432
};
33+
34+
//TODO: add loadBundle and namedQuery to the firestore namespace
3535
}
3636

37-
registerBundle(firestore.FirebaseFirestore);
37+
registerBundle(Firestore);
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@firebase/firestore/memory",
33
"description": "A memory-only build of the Cloud Firestore JS SDK.",
4-
"main": "../dist/index.memory.node.cjs.js",
5-
"main-esm2017": "../dist/index.memory.node.esm2017.js",
4+
"main": "../dist/node-cjs/memory.js",
5+
"main-esm2017": "../dist/node-esm2017/memory.js",
66
"react-native": "../dist/index.memory.rn.esm2017.js",
7-
"browser": "../dist/index.memory.esm.js",
8-
"module": "../dist/index.memory.esm.js",
9-
"esm2017": "../dist/index.memory.esm2017.js",
7+
"browser": "../dist/esm5/memory.js",
8+
"module": "../dist/esm5/memory.js",
9+
"esm2017": "../dist/esm2017/memory.js",
1010
"typings": "../dist/index.d.ts"
1111
}

packages/firestore/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"build:lite": "rollup -c rollup.config.lite.js",
1818
"build:bundle": "rollup -c rollup.config.bundle.js",
1919
"build:exp:release": "yarn build:exp && yarn build:lite",
20+
"build:rn": "rollup -c rollup.config.rn.js",
21+
"build:browser": "rollup -c rollup.config.browser.js",
2022
"predev": "yarn prebuild",
2123
"dev": "rollup -c -w",
2224
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
@@ -52,14 +54,12 @@
5254
"predoc": "node ../../scripts/exp/remove-exp.js temp",
5355
"doc": "api-documenter markdown --input temp --output docs"
5456
},
55-
"main": "dist/index.node.cjs.js",
56-
"main-esm2017": "dist/index.node.esm2017.js",
57+
"main": "dist/node-cjs/index.js",
58+
"main-esm2017": "dist/node-esm2017/index.js",
5759
"react-native": "dist/index.rn.esm2017.js",
58-
"browser": "dist/index.esm.js",
59-
"module": "dist/index.esm.js",
60-
"esm2017": "dist/index.esm2017.js",
61-
"bundle": "dist/index.bundle.js",
62-
"bundleModule": "dist/index.bundle.module.js",
60+
"browser": "dist/esm5/index.js",
61+
"module": "dist/esm5/index.js",
62+
"esm2017": "dist/esm2017/index.js",
6363
"license": "Apache-2.0",
6464
"files": [
6565
"dist",
@@ -87,7 +87,7 @@
8787
"json-stable-stringify": "1.0.1",
8888
"protobufjs": "6.10.1",
8989
"rollup": "2.33.1",
90-
"rollup-plugin-copy-assets": "1.1.0",
90+
"rollup-plugin-copy-assets": "2.0.3",
9191
"@rollup/plugin-json": "4.1.0",
9292
"@rollup/plugin-node-resolve": "9.0.0",
9393
"rollup-plugin-replace": "2.2.0",

packages/firestore/rollup.config.browser.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@
1616
*/
1717

1818
import pkg from './package.json';
19+
import bundlePkg from './bundle/package.json';
20+
import memoryPkg from './memory/package.json';
21+
import path from 'path';
1922

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

2225
export default [
2326
{
24-
input: 'index.ts',
27+
input: {
28+
index: 'index.ts',
29+
memory: 'index.memory.ts',
30+
bundle: 'index.bundle.ts'
31+
},
2532
output: {
26-
file: pkg.esm2017,
33+
dir: 'dist/esm2017',
2734
format: 'es',
2835
sourcemap: true
2936
},
@@ -34,8 +41,16 @@ export default [
3441
}
3542
},
3643
{
37-
input: pkg.esm2017,
38-
output: { file: pkg.module, format: 'es', sourcemap: true },
44+
input: {
45+
index: pkg.esm2017,
46+
memory: path.resolve('./memory', memoryPkg.esm2017),
47+
bundle: path.resolve('./bundle', bundlePkg.esm2017)
48+
},
49+
output: {
50+
dir: 'dist/esm5',
51+
format: 'es',
52+
sourcemap: true
53+
},
3954
plugins: util.es2017ToEs5Plugins(/* mangled= */ true),
4055
external: util.resolveBrowserExterns,
4156
treeshake: {

packages/firestore/rollup.config.browser.memory.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

packages/firestore/rollup.config.bundle.js

Lines changed: 0 additions & 45 deletions
This file was deleted.

packages/firestore/rollup.config.node.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,31 @@
1818
import replace from 'rollup-plugin-replace';
1919
import copy from 'rollup-plugin-copy-assets';
2020
import pkg from './package.json';
21+
import bundlePkg from './bundle/package.json';
22+
import memoryPkg from './memory/package.json';
23+
import path from 'path';
2124

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

2427
export default [
2528
{
26-
input: 'index.node.ts',
29+
input: {
30+
index: 'index.node.ts',
31+
memory: 'index.node.memory.ts',
32+
bundle: 'index.bundle.ts'
33+
},
2734
output: {
28-
file: pkg['main-esm2017'],
35+
dir: 'dist/node-esm2017',
2936
format: 'es',
3037
sourcemap: true
3138
},
3239
plugins: [
3340
...util.es2017Plugins('node'),
34-
// Needed as we also use the *.proto files
35-
copy({
36-
assets: ['./src/protos']
37-
}),
3841
replace({
3942
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('src/protos')
43+
}),
44+
copy({
45+
assets: ['./src/protos']
4046
})
4147
],
4248
external: util.resolveNodeExterns,
@@ -45,8 +51,18 @@ export default [
4551
}
4652
},
4753
{
48-
input: pkg['main-esm2017'],
49-
output: [{ file: pkg.main, format: 'cjs', sourcemap: true }],
54+
input: {
55+
index: pkg['main-esm2017'],
56+
memory: path.resolve('./memory', memoryPkg['main-esm2017']),
57+
bundle: path.resolve('./bundle', bundlePkg['main-esm2017'])
58+
},
59+
output: [
60+
{
61+
dir: 'dist/node-cjs',
62+
format: 'cjs',
63+
sourcemap: true
64+
}
65+
],
5066
plugins: util.es2017ToEs5Plugins(),
5167
external: util.resolveNodeExterns,
5268
treeshake: {

packages/firestore/rollup.config.node.memory.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

packages/firestore/rollup.config.rn.js

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

18-
import pkg from './package.json';
19-
2018
const util = require('./rollup.shared');
2119

2220
export default {
23-
input: 'index.rn.ts',
21+
input: {
22+
index: 'index.rn.ts',
23+
memory: 'index.rn.memory.ts',
24+
bundle: 'index.bundle.ts'
25+
},
2426
output: {
25-
file: pkg['react-native'],
27+
dir: 'dist/rn',
2628
format: 'es',
2729
sourcemap: true
2830
},

0 commit comments

Comments
 (0)