angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.66k stars 2.19k forks source link

AngularFireModule has not been provided in your AppModule when lazy loading Firestore #3404

Open MawRojas opened 1 year ago

MawRojas commented 1 year ago

Version info

Angular: 15.2.9

Firebase: 9.8

AngularFire: 7.5

How to reproduce these conditions

Based on the sample advanced app. Firestore should be able to be lazy loaded.
I've created a getFiresotre file as the sample app indicates:

    import { getFirestore } from '@angular/fire/firestore';
    export const firestore = getFirestore();

The file is localed in the following path: src/app/getFirestore.ts
Then, I'm importing firestore just like the sample app:

    import { firestore } from 'src/app/getFirestore';

However, the getFirestore file throws the following error: Error: Either AngularFireModule has not been provided in your AppModule (this can be done manually or implictly using provideFirebaseApp) or you're calling an AngularFire method outside of an NgModule (which is not supported) The error makes sense, since I'm never providing Firestore in the app.module. However, the sample app does not provide it either.
I have inspected the sample app for the part of the code that provides firestore; nonetheless, I was not able to find it.
Was is the correct way of providing firestore while lazy loading it?

google-oss-bot commented 1 year ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

davideast commented 1 year ago

@MawRojas Can you provide an example on StackBlitz? That would make it much easier to debug.

MawRojas commented 1 year ago

@MawRojas Can you provide an example on StackBlitz? That would make it much easier to debug.

Hello, I've tried to setup the StackBlitz project but I cannot get it to compile when I provide the firebase app in app.module using provideFirebaseApp.
Also, the provided "Angular Fire Start" project, that shows up when submitting a new issue, is using the old angularfire version, 6, so that is not useful in this case.
Could you tell me how to get it to compile? Once that is done I'll replicate the problem I described in this issue. Link to the StackBlitz project

Lastly, I found another project that is setup for angularfire 7 but it also does not compile. I don't know if that is useful but this is the link

davideast commented 1 year ago

@MawRojas After a bit of investigation I think I understand the problem a bit more now. I need to debug a bit more but hang tight!

MawRojas commented 1 year ago

@MawRojas After a bit of investigation I think I understand the problem a bit more now. I need to debug a bit more but hang tight!

Sounds good. Thank you for looking into it.

MawRojas commented 10 months ago

@davideast Hello, any news regarding the lazy loading?