-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
Compatibility with Firebase Modular JS SDK (v9) #1128
Comments
@posva I would be happy to help with the migration to the modular Firebase 9 SDK but unfortunately, I don't really understand how to build the projects (I'm not really into lerna & rollup). Is there anywhere some hint on how to build & test the whole repository? |
@sceee the branch that needs to be updated is https://github.com/vuejs/vuefire/tree/v3 which is the next version of Vuefire that works for both Vue 2 and Vue 3. I haven't checked the breaking changes aside from modules from 8 to 9 but if that's the only breaking change, then it's fine to upgrade it. Tests are currently failing after the upgrade to firebase 8 but it's no longer a lerna monorepo, so it should be easier to handle 🙂 |
@posva thank for the info - I will have a look and see if I can prepare a proposed upgrade. I think there's not yet a changelog available for Firebase SDK v9 (as it's also still in Beta) but according to my information, this seems to be the only change. Anyway, I think the way forward will be v9 and therefore I think it would be good have vuefire support it better earlier than later (maybe also as a separate (alpha/beta) release so that Firebase v8 users can still use vuefire v3 and Firebase v9 users can use vuefire v4 (alpha/beta)?). |
I just noticed that I anyway guess So it would probably be better (and required) to migrate from It unfortunately seems it's getting a bigger change than I initially thought... |
Yes, feel free to do it |
I pushed some work in progress here: https://github.com/sceee/vuefire/tree/firebase-emulators Still, a lot of tests are failing but it's getting better. |
@posva I fixed some more tests (it's now down to ~20 failing) but now I'm getting to a point where I'm getting stuck. I think there are a few groups of issues left:
● refs in collections › keeps array of references when updating a property
TypeError: Cannot read property '0' of undefined
21 | ): Record<string, any> {
22 | // TODO: development warning when target[key] does not exist
> 23 | return path.split('.').reduce((target, key) => target[key], obj)
| ^
24 | }
25 |
26 | /**
at src/shared.ts:23:56
at Array.reduce (<anonymous>)
at Object.walkGet (src/shared.ts:23:26)
at Object.data (src/firestore/index.ts:151:19)
● refs in collections › unbinds refs when the collection is unbound
expect(jest.fn()).toHaveBeenCalledTimes(expected)
Expected number of calls: 1
Received number of calls: 0
128 | await delay(200)
129 |
> 130 | expect(spyA).toHaveBeenCalledTimes(1)
| ^
131 | expect(spyB).toHaveBeenCalledTimes(1)
132 |
133 | spyA.mockRestore()
at Object.<anonymous> (__tests__/core/firestore/refs-collections.spec.ts:130:18) I have the feeling that behavior for the Besides that, I had to make some general adjustments to some tests:
Would you think you have the possibility to take a look at the remaining failing tests (especially the failing If you want to execute the tests locally, please
If you prefer, I could also create a PR (draft) so we move the future discussion over there so we don't spam this issue. Happy to hear what you think. |
I will take a proper look in a few weeks, after some Vue 3 related releases, and try to give you a hand. Have you published your code somewhere? |
Thanks @posva . Yeah, the code is published here https://github.com/sceee/vuefire/tree/firebase-emulators and the latest action run always shows the up to date state. |
Thanks a lot @sceee ! I will get to this probably after a stable release on Pinia with Vue 3.2 |
Thank you both for the work on migrating to v9. Even though v9 is still beta, I am loving it. The API is fantastic and everything is much faster. Just wanted to say keep up the great work! |
How is the progress. I would love to use this library for firebase v9 because it has tree shaking. |
@posva quick question - is the code in |
I think it can be ignored |
Firebase v9 has been released, hope you guys release vuexfire soon. Thanks |
What's the progress on this? |
I initially tried to go to [email protected], the current release, but it redoes the way that module imports work. It seems straightforward to update our code to use the 'compat' versions of the modules per the instructions at https://firebase.google.com/docs/web/modular-upgrade, but the third-party vuefire package doesn't seem to have been updated yet (vuejs/vuefire#1128) so we're stuck at version 8 for now. Also switch from the deprecated @firebase/testing package to @firebase/rules-unit-testing. Luckily, it seems to be a drop-in replacement.
I initially tried to go to [email protected], the current release, but it redoes the way that module imports work. It seems straightforward to update our code to use the 'compat' versions of the modules per the instructions at https://firebase.google.com/docs/web/modular-upgrade, but the third-party vuefire package doesn't seem to have been updated yet (vuejs/vuefire#1128) so we're stuck at version 8 for now. Also switch from the deprecated @firebase/testing package to @firebase/rules-unit-testing. Luckily, it seems to be a drop-in replacement. To get all of this working, I also ripped out all of the code I'd written before to asynchronously import Firebase modules. It made the code way more complicated for what was probably only a little bit of improvement in loading time, and I spent a lot of time trying to figure out how to update it to work with version 8 of the Firebase API before giving up. Version 9 finally supports tree-shaking, so hopefully things will get faster again when we're able to upgrade to it.
I initially tried to go to [email protected], the current release, but it redoes the way that module imports work. It seems straightforward to update our code to use the 'compat' versions of the modules per the instructions at https://firebase.google.com/docs/web/modular-upgrade, but the third-party vuefire package doesn't seem to have been updated yet (vuejs/vuefire#1128) so we're stuck at version 8 for now. Also switch from the deprecated @firebase/testing package to @firebase/rules-unit-testing. Luckily, it seems to be a drop-in replacement. To get all of this working, I also ripped out all of the code I'd written before to asynchronously import Firebase modules. It made the code way more complicated for what was probably only a little bit of improvement in loading time, and I spent a lot of time trying to figure out how to update it to work with version 8 of the Firebase API before giving up. Version 9 finally supports tree-shaking, so hopefully things will get faster again when we're able to upgrade to it.
To all asking/waiting for progress on this - I would really appreciate to get this working but unfortunately, I got stuck while making the tests work using the Firebase emulator as mentioned here. @posva mentioned in some of the comments above he might be able to find some time to help check the remaining (currently failing) tests. Once all the tests work with Firebase 8 using the Firebase emulator, the migration to the v9 modular SDK should be a smaller step. |
I further analyzed the remaining failing tests (roughly ~14-19). Unfortunately, I could not get them to work but at least I now have a better idea what causes some of the failures: To do this, spys are added in tests using Unfortunately, using the Firebase emulators, this code no longer works as before as the replacement The same issue probably applies to the Update: I could see that spying on the unsubscribe function still works for direct references, so the following still works:
But it no longer works for nested refs ( Does maybe someone have an idea how to solve this issue as I could not find a way to intercept these calls to be able to spy on them to make the tests work?Besides that, there also seems to be some timing issue left in the code (maybe un-awaited promises) as some tests sometimes work and sometimes fail with errors like
caused by the |
Hi, I'm really looking forward to this. Vuefire looks like a fantastic solution, but since Vue3 / Vuex 4 / Firebase 9 are the latest stable versions, I'm not keen on adding it to current projects. Do you have a rough estimate of how much work is left to complete? |
@luc122c it's not so much left, see here: https://github.com/sceee/vuefire/runs/5158585563?check_suite_focus=true Mainly this is due to tests failing cause the I think once the tests work, migrating to the new Firebase 9 API is the easier task and should be pretty straightforward. So if anyone has an idea how to get the |
Still needs to be confirmed but I should be able to spend time bringing v9 support to VueFire as well as support for other Firebase packages. Stay tuned! Thanks a lot for the help @sceee, I will keep you updated with an alternative way to spy on unsubscriptions as it would be important to be able to not use |
Looking forward for an update on this topic :) Thanks for the great work! |
Any progress on this in the last 2 months? Can someone please update the docs/install guide so the default vuejs/firebase installation doesn't automatically install an incompatible version, and be more version explicit? |
How do we feel about making a release for firebase v9 using the https://firebase.google.com/docs/web/modular-upgrade#update_imports_to_v9_compat This would unblock v9 upgrades. Funny enough, even the google project firebaseui has done this. I've been trying for a bit but unfortunately I'm not super skilled at all the npm workspace rollup yarn packaging stuff going on in this project. Would be great to have some docs on how to run this project as a lib developer. If we would consider releasing a v9 compat version I can spend some more time on this. Thanks! |
Made a branch here that can be installed like this in package.json:
You then need to add this
Then you need to change your imports like this: import { firestoreAction, vuexfireMutations } from "vuefire/packages/vuexfire"; This is the only way I could make it work. If anyone has better ideas, let me know. This would not be needed if we build and publish a compat version like this. Let me know if that is a route we could take @posva. |
That could work for Firebase, but the Vuefire/Vuexfire compatibility with Vue 3/Vuex 4 is still needed anyway and in my modest opinion it is more important and urgent. There will be somebody that can take over this fantastic plugin and keep working on it sometimes. |
@posva could you please let me know if you'd consider releasing a firebase 9 compat version? Because if not, I'll consider releasing separate npm packages as I need this in several projects and installing from source is error prone due to dev environments. Thanks! |
@posva could you please let me know, as else I'll release and publish a fork that is compatible with firebase 9. Thanks! |
@michi88 I will start working on a new version of Vuefire, compatible with Firebase 9 and more, in the following weeks. |
Is there a reason to use the VueUse firebase package over this one? |
I would also be interested in knowing what you consider the "best" way forward - whether it will be Vue 3 + Pinia + Firebase 9 (how intergrated in Pinia?) or Vue 3 + vuex + "new" vuexfire (with support for Firebase 9). |
Pinia would be preferred as it's the new default state manager for Vue. Vuex has been put into maintenance mode. |
Thanks everybody for the feedback 🙏. I'm currently migrating the library and I hope to start releasing alphas soon. You can follow the advancement at #1241 |
What problem is this solving
Firebase recently introduced the modular web SDK, currently in beta.
One of its goals is to reduce the footprint of the lib allowing tree shaking. Therefore, a lot of users might want to benefit from using it.
Using vuexfire does currently not seem to be working with the new Firebase modular SDK because of the changed API:
See here for the new way the API works. What used to be something like this:
...is now something like this:
That's why I think the
bindFirestoreRef(...)
now needs to be adjusted to adjust to the new API.Proposed solution
As version 9 of the Firebase JS SDK will be the modular one, adjust to the new API so that vuefire/vuexfire works with the Firebase 9 JS SDK.
Describe alternatives you've considered
Stick with Version 8 of the Firebase JS SDK for now.
The text was updated successfully, but these errors were encountered: