angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

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

Open MawRojas opened this issue 2 years ago • 6 comments

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?

MawRojas avatar Jun 29 '23 18:06 MawRojas

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

google-oss-bot avatar Jun 29 '23 18:06 google-oss-bot

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

davideast avatar Jun 30 '23 15:06 davideast

@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

MawRojas avatar Jun 30 '23 18:06 MawRojas

@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!

davideast avatar Jul 10 '23 17:07 davideast

@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 avatar Jul 10 '23 22:07 MawRojas

@davideast Hello, any news regarding the lazy loading?

MawRojas avatar Oct 06 '23 18:10 MawRojas