You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@firebase/database included in the final build while I only use firestore #489
In my app I only provide firestore and I don't use a real-time database but I see it increasing my bundle size. Any advice? (I don't have it imported anywhere).
Hi @jhuleatt I am still running into this issue using the following. Webpack is properly tree-shaking other libraries but reactfire is still loading firestore and storage.
Dependencies
firebase@9.8.4
reactfire@4.2.1
react@17.0.2
webpack@5.73.0
The only firebase imports we are using are "firebase/auth" and "firebase/app".
This is our treemap of the firebase bundle from Lighthouse:
this hack force remove the firebase/database dependency out of the bundle.
why putting Math ? because webpack will add a small line in the bundle : "e.exports=math", so I used a builtin package to export to not crash the whole app
Thanks all for the additional information. We've just published ReactFire 4.2.2, which is the first release with a new build process (#534) that includes a specific list of externals, and I believe solves this issue:
Hi @jhuleatt, Thanks for the update. I upgraded from v4.2.1 to v4.2.2 and ran webpack-bundle-analyzer. It looks like the unused packages from @firebase have been removed, but now the reactfire bundle is massive.
@robertn702 thanks for trying it out! That's a big surprise to me. According to bundlephobia, the bundle is smaller than 4.2.1, not bigger: https://bundlephobia.com/package/reactfire@4.2.2. Any chance your 4.2.1 build reports rxjs or rxfire separately, where 4.2.2 might just report them all combined as reactfire?
Hi @jhuleatt, I am unsure if the issue is on Next.js or Reactifire's end, but when using both, everything from Firebase is pulled in the final bundle just by importing the main app provider in _app.tsx.
@Laityned if it can help, I worked it around by extending the webpack config in the next.js config file like below:
webpack: (config, { isServer }) => {
// we remove unnecessary Firebase packages
// only in production due to tree shaking
if (isProduction) {
decorateConfigWithFirebaseExternals(config);
}
return config;
},
Activity
jhuleatt commentedon Nov 24, 2021
Hi @MaciejCaputa, I think this might be related to an issue I'm investigating #488 (comment).
Just curious, what build tool are you using, and can you please confirm that you have tree-shaking enabled in your build?
robertn702 commentedon Jul 4, 2022
Hi @jhuleatt I am still running into this issue using the following. Webpack is properly tree-shaking other libraries but
reactfireis still loadingfirestoreandstorage.Dependencies
firebase@9.8.4reactfire@4.2.1react@17.0.2webpack@5.73.0The only firebase imports we are using are
"firebase/auth"and"firebase/app".This is our treemap of the firebase bundle from Lighthouse:
alexduhem commentedon Jul 20, 2022
Hey there, got the same issue, I just pulled all my hairs out my head to know what libraries was causing this.
finally I just did a little hack with the webpack config by using https://webpack.js.org/configuration/externals/
config.externals = { 'firebase/database': 'root Math', };this hack force remove the firebase/database dependency out of the bundle.
why putting Math ? because webpack will add a small line in the bundle : "e.exports=math", so I used a builtin package to export to not crash the whole app
jhuleatt commentedon Aug 17, 2022
Thanks all for the additional information. We've just published ReactFire
4.2.2, which is the first release with a new build process (#534) that includes a specific list of externals, and I believe solves this issue:reactfire/vite.config.ts
Lines 13 to 34 in f6d2351
@alexduhem or others - can you please give version
4.2.2a try and see if it fixes this issue without the need for workarounds?robertn702 commentedon Aug 18, 2022
Hi @jhuleatt, Thanks for the update. I upgraded from
v4.2.1tov4.2.2and ranwebpack-bundle-analyzer. It looks like the unused packages from@firebasehave been removed, but now thereactfirebundle is massive.Dependencies
firebase@9.9.1webpack@5.74.0Before
reactfire@firebaseAfter
reactfire@firebasejhuleatt commentedon Aug 18, 2022
@robertn702 thanks for trying it out! That's a big surprise to me. According to bundlephobia, the bundle is smaller than
4.2.1, not bigger: https://bundlephobia.com/package/reactfire@4.2.2. Any chance your4.2.1build reportsrxjsorrxfireseparately, where4.2.2might just report them all combined asreactfire?I'll look into this a bit more. Thanks again!
cc @jamesdaniels
Gbuomprisco commentedon Sep 16, 2022
Hi @jhuleatt, I am unsure if the issue is on Next.js or Reactifire's end, but when using both, everything from Firebase is pulled in the final bundle just by importing the main app provider in
_app.tsx.I have provided a repository to reproduce this issue:
When finished, the browser will open the output below:
Any help would be super appreciated!
Laityned commentedon Nov 22, 2022
I am facing the same issue as @Gbuomprisco
Gbuomprisco commentedon Nov 23, 2022
@Laityned if it can help, I worked it around by extending the webpack config in the next.js config file like below:
Laityned commentedon Nov 23, 2022
Thank you for the work around. I will definitely use it.
Furthermore, I think reactfire should still address the root cause of this problem.
I could help with a PR, if anyone has a clue why it is not tree shaking out firebase.
Gbuomprisco commentedon Nov 23, 2022
The library is basically unmaintained, which is sad.