Skip to content

Commit b08248a

Browse files
Split up firestore and firestore-memory build
We need to verify that the Node build still works
1 parent 66428e0 commit b08248a

File tree

11 files changed

+184
-67
lines changed

11 files changed

+184
-67
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ export interface DocumentChange<T = DocumentData> {
176176
* access will return 'undefined'. You can use the `exists()` method to
177177
* explicitly verify a document's existence.
178178
*/
179-
export class DocumentSnapshot<T = DocumentData> extends LiteDocumentSnapshot<
180-
T
181-
> {
179+
export class DocumentSnapshot<
180+
T = DocumentData
181+
> extends LiteDocumentSnapshot<T> {
182182
private readonly _firestoreImpl: FirebaseFirestore;
183183

184184
/**
@@ -291,9 +291,9 @@ export class DocumentSnapshot<T = DocumentData> extends LiteDocumentSnapshot<
291291
* `exists` property will always be true and `data()` will never return
292292
* 'undefined'.
293293
*/
294-
export class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<
295-
T
296-
> {
294+
export class QueryDocumentSnapshot<
295+
T = DocumentData
296+
> extends DocumentSnapshot<T> {
297297
/**
298298
* Retrieves all fields in the document as an `Object`.
299299
*

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ export class DocumentSnapshot<T = DocumentData> {
211211
* `exists` property will always be true and `data()` will never return
212212
* 'undefined'.
213213
*/
214-
export class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<
215-
T
216-
> {
214+
export class QueryDocumentSnapshot<
215+
T = DocumentData
216+
> extends DocumentSnapshot<T> {
217217
/**
218218
* Retrieves all fields in the document as an `Object`.
219219
*
+6-6
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/node-cjs/memory.js",
5-
"main-esm2017": "../dist/node-esm2017/memory.js",
6-
"react-native": "../dist/rn/memory.js",
7-
"browser": "../dist/esm5/memory.js",
8-
"module": "../dist/esm5/memory.js",
9-
"esm2017": "../dist/esm2017/memory.js",
4+
"main": "../dist/memory/node-cjs/index.js",
5+
"main-esm2017": "../dist/memory/node-esm2017/index.js",
6+
"react-native": "../dist/memory/rn/index.js",
7+
"browser": "../dist/memory/esm5/index.js",
8+
"module": "../dist/memory/esm5/index.js",
9+
"esm2017": "../dist/memory/esm2017/index.js",
1010
"typings": "../dist/index.d.ts"
1111
}

packages/firestore/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"json-stable-stringify": "1.0.1",
8383
"protobufjs": "6.10.2",
8484
"rollup": "2.33.2",
85+
"rollup-plugin-copy": "3.3.0",
8586
"rollup-plugin-copy-assets": "2.0.3",
8687
"rollup-plugin-replace": "2.2.0",
8788
"rollup-plugin-sourcemaps": "0.6.3",

packages/firestore/rollup.config.browser.js

+47-15
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ import bundlePkg from './bundle/package.json';
2020
* limitations under the License.
2121
*/
2222

23-
const alias = require('@rollup/plugin-alias');
2423
const util = require('./rollup.shared');
2524

2625
export default [
26+
// Create a temporary build that includes the mangled classes for all exports
2727
{
2828
input: 'export.ts',
2929
output: {
30-
file: 'dist/prebuild.js',
30+
file: 'dist/prebuilt.js',
3131
format: 'es',
3232
sourcemap: true
3333
},
@@ -37,10 +37,10 @@ export default [
3737
moduleSideEffects: false
3838
}
3939
},
40+
// Create main build
4041
{
4142
input: {
4243
index: 'index.ts',
43-
memory: 'index.memory.ts',
4444
bundle: 'index.bundle.ts'
4545
},
4646
output: {
@@ -49,25 +49,18 @@ export default [
4949
sourcemap: true
5050
},
5151
plugins: [
52-
alias({
53-
entries: [
54-
{
55-
find: /^(.*)\/export$/,
56-
replacement: `$1\/dist/prebuild.js`
57-
}
58-
]
59-
}),
60-
...util.es2017Plugins('browser', /* mangled= */ false)
52+
util.applyPrebuilt(),
53+
...util.es2017Plugins('browser', /* mangled= */ true)
6154
],
6255
external: util.resolveBrowserExterns,
6356
treeshake: {
6457
moduleSideEffects: false
6558
}
6659
},
60+
// Convert main build to ES5
6761
{
6862
input: {
6963
index: pkg['esm2017'],
70-
memory: path.resolve('./memory', memoryPkg['esm2017']),
7164
bundle: path.resolve('./bundle', bundlePkg['esm2017'])
7265
},
7366
output: [
@@ -77,8 +70,47 @@ export default [
7770
sourcemap: true
7871
}
7972
],
80-
plugins: util.es2017ToEs5Plugins(),
81-
external: util.resolveNodeExterns,
73+
plugins: util.es2017ToEs5Plugins(/* mangled= */ true),
74+
external: util.resolveBrowserExterns,
75+
treeshake: {
76+
moduleSideEffects: false
77+
}
78+
},
79+
// Create memory build
80+
{
81+
input: {
82+
index: 'index.memory.ts',
83+
bundle: 'index.bundle.ts'
84+
},
85+
output: {
86+
dir: 'dist/memory/esm2017',
87+
format: 'es',
88+
sourcemap: true
89+
},
90+
plugins: [
91+
util.applyPrebuilt(),
92+
...util.es2017Plugins('browser', /* mangled= */ true)
93+
],
94+
external: util.resolveBrowserExterns,
95+
treeshake: {
96+
moduleSideEffects: false
97+
}
98+
},
99+
// Convert memory build to ES5
100+
{
101+
input: {
102+
index: path.resolve('./memory', memoryPkg['esm2017']),
103+
bundle: path.resolve('./bundle', bundlePkg['esm2017'])
104+
},
105+
output: [
106+
{
107+
dir: 'dist/memory/esm5',
108+
format: 'es',
109+
sourcemap: true
110+
}
111+
],
112+
plugins: util.es2017ToEs5Plugins(/* mangled= */ true),
113+
external: util.resolveBrowserExterns,
82114
treeshake: {
83115
moduleSideEffects: false
84116
}

packages/firestore/rollup.config.node.js

+41-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import replace from 'rollup-plugin-replace';
19-
import copy from 'rollup-plugin-copy-assets';
19+
import copy from 'rollup-plugin-copy';
2020
import pkg from './package.json';
2121
import bundlePkg from './bundle/package.json';
2222
import memoryPkg from './memory/package.json';
@@ -28,7 +28,6 @@ export default [
2828
{
2929
input: {
3030
index: 'index.node.ts',
31-
memory: 'index.node.memory.ts',
3231
bundle: 'index.bundle.ts'
3332
},
3433
output: {
@@ -39,10 +38,10 @@ export default [
3938
plugins: [
4039
...util.es2017Plugins('node'),
4140
replace({
42-
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('src/protos')
41+
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('../protos')
4342
}),
4443
copy({
45-
assets: ['./src/protos']
44+
targets: [{ src: 'src/protos', dest: 'dist' }]
4645
})
4746
],
4847
external: util.resolveNodeExterns,
@@ -53,7 +52,6 @@ export default [
5352
{
5453
input: {
5554
index: pkg['main-esm2017'],
56-
memory: path.resolve('./memory', memoryPkg['main-esm2017']),
5755
bundle: path.resolve('./bundle', bundlePkg['main-esm2017'])
5856
},
5957
output: [
@@ -68,5 +66,43 @@ export default [
6866
treeshake: {
6967
moduleSideEffects: false
7068
}
69+
},
70+
{
71+
input: {
72+
index: 'index.node.memory.ts',
73+
bundle: 'index.bundle.ts'
74+
},
75+
output: {
76+
dir: 'dist/memory/node-esm2017',
77+
format: 'es',
78+
sourcemap: true
79+
},
80+
plugins: [
81+
...util.es2017Plugins('node'),
82+
replace({
83+
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('../protos')
84+
})
85+
],
86+
external: util.resolveNodeExterns,
87+
treeshake: {
88+
moduleSideEffects: false
89+
}
90+
},
91+
{
92+
input: {
93+
index: path.resolve('./memory', memoryPkg['main-esm2017']),
94+
bundle: path.resolve('./bundle', bundlePkg['main-esm2017'])
95+
},
96+
output: [
97+
{
98+
dir: 'dist/memory/node-cjs',
99+
format: 'cjs',
100+
sourcemap: true
101+
}
102+
],
103+
external: util.resolveNodeExterns,
104+
treeshake: {
105+
moduleSideEffects: false
106+
}
71107
}
72108
];

packages/firestore/rollup.config.rn.js

+25-12
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
* limitations under the License.
1616
*/
1717

18-
const alias = require('@rollup/plugin-alias');
1918
const util = require('./rollup.shared');
2019

2120
export default [
21+
// Create a temporary build that includes the mangled classes for all exports
2222
{
2323
input: 'export.ts',
2424
output: {
25-
file: 'dist/prebuild.rn.js',
25+
file: 'dist/prebuilt.rn.js',
2626
format: 'es',
2727
sourcemap: true
2828
},
@@ -32,10 +32,10 @@ export default [
3232
moduleSideEffects: false
3333
}
3434
},
35+
// Create main build
3536
{
3637
input: {
3738
index: 'index.ts',
38-
memory: 'index.memory.ts',
3939
bundle: 'index.bundle.ts'
4040
},
4141
output: {
@@ -44,15 +44,28 @@ export default [
4444
sourcemap: true
4545
},
4646
plugins: [
47-
alias({
48-
entries: [
49-
{
50-
find: /^(.*)\/export$/,
51-
replacement: `$1\/dist/prebuild.rn.js`
52-
}
53-
]
54-
}),
55-
...util.es2017Plugins('rn', /* mangled= */ false)
47+
util.applyPrebuilt('prebuilt.rn.js'),
48+
...util.es2017Plugins('rn', /* mangled= */ true)
49+
],
50+
external: util.resolveBrowserExterns,
51+
treeshake: {
52+
moduleSideEffects: false
53+
}
54+
},
55+
// Create memory build
56+
{
57+
input: {
58+
index: 'index.memory.ts',
59+
bundle: 'index.bundle.ts'
60+
},
61+
output: {
62+
dir: 'dist/rn',
63+
format: 'es',
64+
sourcemap: true
65+
},
66+
plugins: [
67+
util.applyPrebuilt('prebuilt.rn.js'),
68+
...util.es2017Plugins('rn', /* mangled= */ true)
5669
],
5770
external: util.resolveBrowserExterns,
5871
treeshake: {

packages/firestore/rollup.shared.js

+11
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ const manglePrivatePropertiesOptions = {
203203
};
204204
exports.manglePrivatePropertiesOptions = manglePrivatePropertiesOptions;
205205

206+
exports.applyPrebuilt = function (name = 'prebuilt.js') {
207+
alias({
208+
entries: [
209+
{
210+
find: /^(.*)\/export$/,
211+
replacement: `$1\/dist/${name}.js`
212+
}
213+
]
214+
});
215+
};
216+
206217
exports.es2017Plugins = function (platform, mangled = false) {
207218
if (mangled) {
208219
return [

packages/firestore/test/integration/api/query.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ apiDescribe('Queries', (persistence: boolean) => {
155155
.onSnapshot(storeLimitEvent.storeEvent);
156156

157157
// Setup mirroring `limitToLast` query
158-
const storeLimitToLastEvent = new EventsAccumulator<
159-
firestore.QuerySnapshot
160-
>();
158+
const storeLimitToLastEvent = new EventsAccumulator<firestore.QuerySnapshot>();
161159
let limitToLastUnlisten = collection
162160
.orderBy('sort', 'desc')
163161
.limitToLast(2)

packages/firestore/test/unit/specs/spec_builder.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1042,9 +1042,9 @@ export class SpecBuilder {
10421042
return {
10431043
key: SpecBuilder.keyToSpec(doc.key),
10441044
version: doc.version.toMicroseconds(),
1045-
value: userDataWriter.convertValue(doc.toProto()) as JsonObject<
1046-
unknown
1047-
>,
1045+
value: userDataWriter.convertValue(
1046+
doc.toProto()
1047+
) as JsonObject<unknown>,
10481048
options: {
10491049
hasLocalMutations: doc.hasLocalMutations,
10501050
hasCommittedMutations: doc.hasCommittedMutations

0 commit comments

Comments
 (0)