Skip to content

Commit 9776fc4

Browse files
authored
fix compat cdn builds (#4895)
* fix compat cdn builds * fix if condition * omit peerdependencies
1 parent d742823 commit 9776fc4

File tree

4 files changed

+91
-12
lines changed

4 files changed

+91
-12
lines changed

packages-exp/app-compat/src/lite/firebaseNamespaceLite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export function createFirebaseNamespaceLite(): FirebaseNamespace {
4040
// only allow performance to register with firebase lite
4141
if (
4242
component.type === ComponentType.PUBLIC &&
43-
component.name !== 'performance' &&
44-
component.name !== 'installations'
43+
!component.name.includes('performance') &&
44+
!component.name.includes('installations')
4545
) {
4646
throw Error(`${name} cannot register with the standalone perf instance`);
4747
}

packages-exp/firebase-exp/compat/rollup.config.release.js

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,40 @@ const componentBuilds = compatPkg.components
206206
})
207207
.reduce((a, b) => a.concat(b), []);
208208

209+
const aliasForCompleteCDNBuild = compatPkg.components
210+
.filter(component => {
211+
return (
212+
component !== 'firestore' &&
213+
component !== 'storage' &&
214+
component !== 'database'
215+
);
216+
})
217+
.map(component => ({
218+
find: `@firebase/${component}`,
219+
replacement: `@firebase/${component}-exp`
220+
}))
221+
.concat([
222+
{
223+
find: '@firebase/installations',
224+
replacement: '@firebase/installations-exp'
225+
},
226+
{
227+
// hack to locate firestore-compat
228+
find: '@firebase/firestore-compat',
229+
replacement: 'firestore-compat'
230+
},
231+
{
232+
// hack to locate storage-compat
233+
find: '@firebase/storage-compat',
234+
replacement: 'storage-compat'
235+
},
236+
{
237+
// hack to locate database-compat
238+
find: '@firebase/database-compat',
239+
replacement: 'database-compat'
240+
}
241+
]);
242+
209243
/**
210244
* Complete Package Builds
211245
*/
@@ -230,10 +264,19 @@ const completeBuilds = [
230264
output: {
231265
file: 'firebase-compat.js',
232266
format: 'umd',
233-
sourcemap: true,
267+
// disable sourcemap, otherwise build will fail with Error: Multiple conflicting contents for sourcemap source
268+
// TODO: I think it's related to the alias() we are using, so let's try to reenable it for GA.
269+
sourcemap: false,
234270
name: GLOBAL_NAME
235271
},
236-
plugins: [...plugins, typescriptPluginUMD, terser()]
272+
plugins: [
273+
...plugins,
274+
typescriptPluginUMD,
275+
terser(),
276+
alias({
277+
entries: aliasForCompleteCDNBuild
278+
})
279+
]
237280
},
238281
/**
239282
* App Node.js Builds
@@ -280,7 +323,27 @@ const completeBuilds = [
280323
typescriptPluginUMD,
281324
json(),
282325
commonjs(),
283-
terser()
326+
terser({
327+
format: {
328+
comments: false
329+
}
330+
}),
331+
alias({
332+
entries: [
333+
{
334+
find: '@firebase/app',
335+
replacement: '@firebase/app-exp'
336+
},
337+
{
338+
find: `@firebase/performance`,
339+
replacement: `@firebase/performance-exp`
340+
},
341+
{
342+
find: '@firebase/installations',
343+
replacement: '@firebase/installations-exp'
344+
}
345+
]
346+
})
284347
]
285348
},
286349
/**
@@ -312,7 +375,27 @@ const completeBuilds = [
312375
preferConst: true
313376
}),
314377
commonjs(),
315-
terser()
378+
terser({
379+
format: {
380+
comments: false
381+
}
382+
}),
383+
alias({
384+
entries: [
385+
{
386+
find: '@firebase/app',
387+
replacement: '@firebase/app-exp'
388+
},
389+
{
390+
find: `@firebase/performance`,
391+
replacement: `@firebase/performance-exp`
392+
},
393+
{
394+
find: '@firebase/installations',
395+
replacement: '@firebase/installations-exp'
396+
}
397+
]
398+
})
316399
]
317400
}
318401
];

packages-exp/remote-config-exp/rollup.config.release.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const es5Builds = es5BuildsNoPlugin.map(build => ({
3838
...build,
3939
plugins: es5BuildPlugins,
4040
treeshake: {
41-
moduleSideEffects: false
41+
moduleSideEffects: (id, external) => id === '@firebase/installations'
4242
}
4343
}));
4444

@@ -66,7 +66,7 @@ const es2017Builds = es2017BuildsNoPlugin.map(build => ({
6666
...build,
6767
plugins: es2017BuildPlugins,
6868
treeshake: {
69-
moduleSideEffects: false
69+
moduleSideEffects: (id, external) => id === '@firebase/installations'
7070
}
7171
}));
7272

scripts/exp/prepare-util.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ export async function createCompatProject(config: CompatConfig) {
6868
[srcPkgJson.name]: srcPkgJson.version
6969
};
7070

71-
compatPkgJson.peerDependencies = {
72-
'@firebase/app': '0.x'
73-
};
74-
7571
compatPkgJson.files = ['dist'];
7672

7773
return `${JSON.stringify(compatPkgJson, null, 2)}\n`;

0 commit comments

Comments
 (0)