nuxt-community / firebase-module

🔥 Easily integrate Firebase into your Nuxt project. 🔥
https://firebase.nuxtjs.org
MIT License
640 stars 99 forks source link

Firebase v9 - Switch to Modular Syntax #597

Open lupas opened 2 years ago

lupas commented 2 years ago

Background

With Version 9 of the Firebase JS SDK, Firebase is adopting a new module first format that is optimized for elimination of unused code. The result is a potential significant reduction of Firebase library code in JavaScript bundles with a reduction of up to 80% in some scenarios. The way the Firebase modules are imported changed completely and does not really support the way this module injects Firebase into your Nuxt app.

This module was written for the Firebase Javascript SDK Version 8 and prior. It is currently not compatible with the new Version 9 supporting tree-shaking. To make it compatible with the new version while keeping the benefits of the new version, the module would most likely need to be re-written completely.

Current Situation (Compat Syntax)

From v8.0.0, this module makes use of the compat syntax of Firebase v9, which allows to at least use Firebase v9, but still with the old syntax. This is not future proof and will not work from v10 on forwards.

Future of this module (Modular Syntax)

It is currently unclear when, and if, this module will support modular syntax (i.e. Firebase version 10+).

The module needs to become lighter, only focussing on the nuxt-specific issues at hand, while keeping the flexibility of using the benefits of the newer Firebase SDK modular mode.

I personally won't find much time to re-write this module in the next few months. I might, but I can't promise. So if you are interested in working on it, let me know by creating a merge request, I would greatly appreciate it.

lupas commented 2 years ago

Want to use the Modular Syntax?

If you want to use Firebase version 9 in the new modular syntax, you can quite easily implement Firebase yourself as described step-by-step in the following medium article. The approach is straight-forward and not much harder than using this module.

This approach allows you to use three-shaking and all the features of the new version, while staying more flexible with future changes in the SDK.

bluequantum commented 2 years ago

would love to help, but i have no idea how to start. i would love to use version 9+ of firebase my bundle size is too big

rahulkumarsingh73690 commented 2 years ago

would love to help, but i have no idea how to start. i would love to use version 9+ of firebase my bundle size is too big

+1

1shaked commented 2 years ago

+1

guillaumeprevost commented 2 years ago

+1