Skip to content

Commit 931621e

Browse files
authored
A few fixes for Firestore bundle sdk builds (#4177)
* Actually creates firebase/firestore/bundle package.json * Fix standard node/browser builds for bundles * Make it release from remote branch. * Add bundle to firebase complete build and fix missing proto for memory build. * Make rollup.config.js more organized. * Revert "Make it release from remote branch." This reverts commit 2c91fd1. * 2017 -> 2020 * Update comment.
1 parent aae9956 commit 931621e

15 files changed

+189
-7
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '@firebase/firestore/bundle';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "firebase/firestore/bundle",
3+
"description": "The bundle loading feature of the Cloud Firestore component.",
4+
"main": "dist/index.node.cjs.js",
5+
"module": "dist/index.esm.js",
6+
"typings": "../empty-import.d.ts"
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '@firebase/firestore';
19+
import '@firebase/firestore/bundle';

packages/firebase/firestore/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@
1616
*/
1717

1818
import '@firebase/firestore';
19-
import '@firebase/firestore/bundle';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/**
19+
* This file serves as the public entrypoint for users that import
20+
* `firebase/firestore/memory`.
21+
*/
22+
23+
import '@firebase/firestore/memory-bundle';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "firebase/firestore/memory",
3+
"description": "The bundle loading feature for the memory-only build of the Cloud Firestore JS SDK.",
4+
"main": "dist/index.node.cjs.js",
5+
"module": "dist/index.esm.js",
6+
"typings": "../../empty-import.d.ts"
7+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/**
19+
* This file serves as the public entrypoint for users that import
20+
* `firebase/firestore/memory`.
21+
*/
22+
23+
import '@firebase/firestore/memory';
24+
import '@firebase/firestore/memory-bundle';

packages/firebase/firestore/memory/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@
2121
*/
2222

2323
import '@firebase/firestore/memory';
24-
import '@firebase/firestore/memory-bundle';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "firebase/firestore",
33
"description": "The Cloud Firestore component of the Firebase JS SDK.",
4-
"main": "dist/index.cjs.js",
4+
"main": "dist/index.node.cjs.js",
55
"module": "dist/index.esm.js",
66
"typings": "../empty-import.d.ts"
77
}

packages/firebase/rollup.config.js

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ import pkg from './package.json';
2828

2929
import appPkg from './app/package.json';
3030

31+
import firestorePkg from './firestore/package.json';
32+
import firestoreBundlePkg from './firestore/bundle/package.json';
33+
34+
import firestoreMemoryPkg from './firestore/memory/package.json';
35+
import firestoreMemoryBundlePkg from './firestore/memory/bundle/package.json';
36+
3137
function createUmdOutputConfig(output) {
3238
return {
3339
file: output,
@@ -111,7 +117,9 @@ const appBuilds = [
111117

112118
const componentBuilds = pkg.components
113119
// The "app" component is treated differently because it doesn't depend on itself.
114-
.filter(component => component !== 'app')
120+
// The "firestore" component is treated differently because it contains multiple
121+
// sub components for different builds.
122+
.filter(component => component !== 'app' && component !== 'firestore')
115123
.map(component => {
116124
const pkg = require(`./${component}/package.json`);
117125
return [
@@ -149,17 +157,67 @@ const componentBuilds = pkg.components
149157
})
150158
.reduce((a, b) => a.concat(b), []);
151159

160+
const firestoreBuilds = [
161+
{
162+
input: `firestore/index.ts`,
163+
output: [
164+
{
165+
file: resolve('firestore', firestorePkg.main),
166+
format: 'cjs',
167+
sourcemap: true
168+
},
169+
{
170+
file: resolve('firestore', firestorePkg.module),
171+
format: 'es',
172+
sourcemap: true
173+
}
174+
],
175+
plugins,
176+
external
177+
},
178+
{
179+
input: `firestore/bundle/index.ts`,
180+
output: [
181+
{
182+
file: resolve('firestore/bundle', firestoreBundlePkg.main),
183+
format: 'cjs',
184+
sourcemap: true
185+
},
186+
{
187+
file: resolve('firestore/bundle', firestoreBundlePkg.module),
188+
format: 'es',
189+
sourcemap: true
190+
}
191+
],
192+
plugins,
193+
external
194+
},
195+
{
196+
input: `firestore/index.cdn.ts`,
197+
output: createUmdOutputConfig(`firebase-firestore.js`),
198+
plugins: [
199+
...plugins,
200+
uglify({
201+
output: {
202+
ascii_only: true // escape unicode chars
203+
}
204+
})
205+
],
206+
external: ['@firebase/app']
207+
}
208+
];
209+
152210
const firestoreMemoryBuilds = [
153211
{
154212
input: `firestore/memory/index.ts`,
155213
output: [
156214
{
157-
file: resolve('firestore/memory', pkg.main),
215+
file: resolve('firestore/memory', firestoreMemoryPkg.main),
158216
format: 'cjs',
159217
sourcemap: true
160218
},
161219
{
162-
file: resolve('firestore/memory', pkg.module),
220+
file: resolve('firestore/memory', firestoreMemoryPkg.module),
163221
format: 'es',
164222
sourcemap: true
165223
}
@@ -168,7 +226,27 @@ const firestoreMemoryBuilds = [
168226
external
169227
},
170228
{
171-
input: `firestore/memory/index.ts`,
229+
input: `firestore/memory/bundle/index.ts`,
230+
output: [
231+
{
232+
file: resolve('firestore/memory/bundle', firestoreMemoryBundlePkg.main),
233+
format: 'cjs',
234+
sourcemap: true
235+
},
236+
{
237+
file: resolve(
238+
'firestore/memory/bundle',
239+
firestoreMemoryBundlePkg.module
240+
),
241+
format: 'es',
242+
sourcemap: true
243+
}
244+
],
245+
plugins,
246+
external
247+
},
248+
{
249+
input: `firestore/memory/index.cdn.ts`,
172250
output: createUmdOutputConfig(`firebase-firestore.memory.js`),
173251
plugins: [...plugins, uglify()],
174252
external: ['@firebase/app']
@@ -276,6 +354,7 @@ const completeBuilds = [
276354
export default [
277355
...appBuilds,
278356
...componentBuilds,
357+
...firestoreBuilds,
279358
...firestoreMemoryBuilds,
280359
...completeBuilds
281360
];

packages/firebase/src/index.cdn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { name, version } from '../package.json';
3333
import '../auth';
3434
import '../database';
3535
import '../firestore';
36+
import '../firestore/bundle';
3637
import '../functions';
3738
import '../messaging';
3839
import '../storage';

packages/firebase/src/index.node.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { name, version } from '../package.json';
2121
import '../auth';
2222
import '../database';
2323
import '../firestore';
24+
import '../firestore/bundle';
2425
import '../functions';
2526

2627
firebase.registerVersion(name, version, 'node');

packages/firebase/src/index.rn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import '../database';
2424
// `atob`). We should provide a RN build that works out of the box.
2525
import '../storage';
2626
import '../firestore';
27+
import '../firestore/bundle';
2728

2829
firebase.registerVersion(name, version, 'rn');
2930

packages/firebase/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { name, version } from '../package.json';
4242
import '../auth';
4343
import '../database';
4444
import '../firestore';
45+
import '../firestore/bundle';
4546
import '../functions';
4647
import '../messaging';
4748
import '../storage';

packages/firestore/rollup.config.node.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export default [
8282
...util.es2017Plugins('node'),
8383
replace({
8484
'process.env.FIRESTORE_PROTO_ROOT': JSON.stringify('../protos')
85+
}),
86+
copy({
87+
targets: [{ src: 'src/protos', dest: 'dist/memory' }]
8588
})
8689
],
8790
external: util.resolveNodeExterns,

0 commit comments

Comments
 (0)