Skip to content

FR: Module is huge, consider splitting it into many submodules (inside same repo) and lazy loading, bundle size #4862

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

Closed
OZZlE opened this issue May 4, 2021 · 7 comments

Comments

@OZZlE
Copy link

OZZlE commented May 4, 2021

[REQUIRED] Describe your environment

  • Operating System version: Not applicable.
  • Browser version: Not applicable.
  • Firebase SDK version: 8.4.3
  • Firebase Product: auth

[REQUIRED] Describe the problem

Steps to reproduce:

yarn add firebase || npm install firebase
import 'firebase/auth' # 61.1 KB gzipped, 199.6 KB not gzipped!
import firebase from 'firebase/app' # 7.6 KB gzipped, 23.5 KB not gzipped

firebase.initializeApp(config)
this.auth = firebase.auth()

This is by far the biggest third party module we use and it's not easily replaceable by own code.

If it's because the module is very framework generic, perhaps making specific versions is better, like react-firebase, angular-firebase, vue-firebase etc.

@OZZlE OZZlE changed the title FR: Module is huge, consider splitting it into many submodules (inside same repo) and lazy loading FR: Module is huge, consider splitting it into many submodules (inside same repo) and lazy loading, bundle size May 4, 2021
@OZZlE
Copy link
Author

OZZlE commented May 4, 2021

@Feiyang1
Copy link
Member

Feiyang1 commented May 4, 2021

Have you tried the v9 beta SDK, which is modular and tree shakable? See #4791 for our announcement

@Feiyang1
Copy link
Member

Feiyang1 commented May 4, 2021

duplicate of #332.
I will close the issue, but feel free to open a discussion thread for specific things you'd like to bring up.

@OZZlE
Copy link
Author

OZZlE commented May 10, 2021

Thanks, it decreased 56.6KB(!) but it's still 166.5 KB for handling login (in our case).. so better but not awesome

@laurentpayot
Copy link

laurentpayot commented May 11, 2021

@OZZlE what sorts of authentication are you using? My OAuth-only chunk is ±80 KB uncompressed (generated by Rollup with terser plugin) and ±22 KB brotli compressed.

@OZZlE
Copy link
Author

OZZlE commented May 11, 2021

import 'firebase/compat/auth' # 140.4KB (gzipped 40.4K)
import firebase from 'firebase/compat/app' # 26.1 KB (gzipped 8.9K)

We use OAuth, magic email link and login with username/pw. We use webpack.

Maybe not huge gzipped but still the biggest node module we have as far as I can see.

we use now use:

"firebase": "9.0.0-beta.1",

@laurentpayot
Copy link

From your import lines I can see you're using the compatibility library. From the docs:

Compat libraries have little to no size or performance advantages over their version 8 counterparts.

I think the small size reduction you're experiencing only comes from the complete Firebase rewrite. To get the benefits of tree shaking you have to use the "real" modular V9 version.

@firebase firebase locked and limited conversation to collaborators Jun 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants