Skip to content

fix compat cdn builds #4895

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 3 commits into from
May 13, 2021
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
4 changes: 2 additions & 2 deletions packages-exp/app-compat/src/lite/firebaseNamespaceLite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export function createFirebaseNamespaceLite(): FirebaseNamespace {
// only allow performance to register with firebase lite
if (
component.type === ComponentType.PUBLIC &&
component.name !== 'performance' &&
component.name !== 'installations'
!component.name.includes('performance') &&
!component.name.includes('installations')
) {
throw Error(`${name} cannot register with the standalone perf instance`);
}
Expand Down
91 changes: 87 additions & 4 deletions packages-exp/firebase-exp/compat/rollup.config.release.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,40 @@ const componentBuilds = compatPkg.components
})
.reduce((a, b) => a.concat(b), []);

const aliasForCompleteCDNBuild = compatPkg.components
.filter(component => {
return (
component !== 'firestore' &&
component !== 'storage' &&
component !== 'database'
);
})
.map(component => ({
find: `@firebase/${component}`,
replacement: `@firebase/${component}-exp`
}))
.concat([
{
find: '@firebase/installations',
replacement: '@firebase/installations-exp'
},
{
// hack to locate firestore-compat
find: '@firebase/firestore-compat',
replacement: 'firestore-compat'
},
{
// hack to locate storage-compat
find: '@firebase/storage-compat',
replacement: 'storage-compat'
},
{
// hack to locate database-compat
find: '@firebase/database-compat',
replacement: 'database-compat'
}
]);

/**
* Complete Package Builds
*/
Expand All @@ -230,10 +264,19 @@ const completeBuilds = [
output: {
file: 'firebase-compat.js',
format: 'umd',
sourcemap: true,
// disable sourcemap, otherwise build will fail with Error: Multiple conflicting contents for sourcemap source
// TODO: I think it's related to the alias() we are using, so let's try to reenable it for GA.
sourcemap: false,
name: GLOBAL_NAME
},
plugins: [...plugins, typescriptPluginUMD, terser()]
plugins: [
...plugins,
typescriptPluginUMD,
terser(),
alias({
entries: aliasForCompleteCDNBuild
})
]
},
/**
* App Node.js Builds
Expand Down Expand Up @@ -280,7 +323,27 @@ const completeBuilds = [
typescriptPluginUMD,
json(),
commonjs(),
terser()
terser({
format: {
comments: false
}
}),
alias({
entries: [
{
find: '@firebase/app',
replacement: '@firebase/app-exp'
},
{
find: `@firebase/performance`,
replacement: `@firebase/performance-exp`
},
{
find: '@firebase/installations',
replacement: '@firebase/installations-exp'
}
]
})
]
},
/**
Expand Down Expand Up @@ -312,7 +375,27 @@ const completeBuilds = [
preferConst: true
}),
commonjs(),
terser()
terser({
format: {
comments: false
}
}),
alias({
entries: [
{
find: '@firebase/app',
replacement: '@firebase/app-exp'
},
{
find: `@firebase/performance`,
replacement: `@firebase/performance-exp`
},
{
find: '@firebase/installations',
replacement: '@firebase/installations-exp'
}
]
})
]
}
];
Expand Down
4 changes: 2 additions & 2 deletions packages-exp/remote-config-exp/rollup.config.release.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const es5Builds = es5BuildsNoPlugin.map(build => ({
...build,
plugins: es5BuildPlugins,
treeshake: {
moduleSideEffects: false
moduleSideEffects: (id, external) => id === '@firebase/installations'
}
}));

Expand Down Expand Up @@ -66,7 +66,7 @@ const es2017Builds = es2017BuildsNoPlugin.map(build => ({
...build,
plugins: es2017BuildPlugins,
treeshake: {
moduleSideEffects: false
moduleSideEffects: (id, external) => id === '@firebase/installations'
}
}));

Expand Down
4 changes: 0 additions & 4 deletions scripts/exp/prepare-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ export async function createCompatProject(config: CompatConfig) {
[srcPkgJson.name]: srcPkgJson.version
};

compatPkgJson.peerDependencies = {
'@firebase/app': '0.x'
};

compatPkgJson.files = ['dist'];

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