Skip to content

firebase/auth and firebase/database treeshaking please #6502

Open
@fserb

Description

@fserb

Current firebase: 9.9.1

Some of firebase's modules are tree-shaking friendly, but some still aren't. In particular, firebase/database and firebase/auth.

For example, I have a module that doesn't need to do actual authentication, but just get persistence storage, and generate tokens. But even just importing getAuth (import {getAuth} from "firebase/auth";) still brings +300kb out of the file's 400kb to the rollup bundle (80kb after terser, etc, but still). Things that get included: all the *AuthProvider(); all *Persistence(); Subscription, Redirects, etc.

I know that the new philosophy behind the SDK is to support function-based import, and I think some other modules saw a big difference. But this still hurts quite a bit.

A similar problem with firebase/database. If you only want to get/set values from the realtime database, you must import almost the whole file for something that can be actually replaced by a fetch with token to the REST API.

Right now, doing:

import {initializeApp} from "firebase/app";
import {getAuth} from "firebase/auth";
import {getDatabase} from "firebase/database";

const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getDatabase(auth);

and bundling with rollup generates a 738kb pre-terser (193kb after) and those two modules are the biggest offender.

Maybe there's a magical rollupConfig.treeshake option that I'm missing, but it would be nice to have a solutions for those.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions