Lazy-load the Firestore with standalone components
- Lenguaje dominante
- TypeScript
- Estrellas
- 7.8k
- Forks
- 2.2k
- Merge medio
- 22 h 28 min
- PR fusionados (30 d)
- 6
Descripción
Hi, is there a way to lazy-load the Firestore?
I'm using it only in a lazy-loaded component, so I would like to avoid providing it in the app config with
`provideFirestore(() => getFirestore())`
I followed this example: https://github.com/angular/angularfire/blob/main/samples/advanced/src/app/firestore/firestore.component.ts
I have a `get-firestore.ts` with this content:
```
import { getFirestore } from '@angular/fire/firestore';
export const firestore = getFirestore();
```
and I try to lazy-load it like this:
```
constructor() {
this.initFirestore();
}
private async initFirestore() {
const { firestore } = await import('./get-firestore');
this.firestore = firestore;
}
```
But I get this error at run-time:
```
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).
```
Even if I add the `AngularFireModule` to the component's imports, it doesn't change.
So, what's the right way to lazy-load the FIrestore, with standalone components?
### Version info
**Angular:** 19.0.0
**Firebase:** 10.12.0
**AngularFire:** 18.0.1
Guía de contribución
Línea de trabajo
Empieza leyendo el componente independiente `get-firestore.ts` y los puntos de entrada `provideFirestore`/`getFirestore` que se muestran en el informe. Reproduce el error en tiempo de ejecución con las versiones indicadas de Angular, Firebase y AngularFire, y después documenta o implementa la ruta de carga diferida compatible y verifica que Firestore no se inicialice en la configuración de la aplicación.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- angular, firebase, typescript
- Área
- database, frontend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 30/100