Closed mazlano27 closed 3 years ago
Upgrade your version of @angular/fire - I believe this is a bug with the current version you are using.
I am having the same issue in @angular/fire 5.1.3 with this providers line:
providers: [{ provide: FirebaseOptionsToken, useValue: environment.firebase }, ],
Works fine for ng build
but breaks with above error when running ng build --prod
ERROR in src\app\app.module.ts(63,26): Error during template compile of 'AppModule'
Only initialized variables and constants can be referenced in decorators because the value of this variable is needed by the template compiler in 'FirebaseOptionsToken'
'FirebaseOptionsToken' is not initialized at @angular\fire\firebase.app.module.ts(9,22).
I tried running ng build --prod
with identical environment.ts and environment.prod.ts files but received the same error.
Is this a bug or am I doing something not smart?
Edit with more info:
I tried downgrading @angular/fire to 5.1.1 and the error remained. I also tried downgrading firebase to 5.10.1 with no change.
A manual workaround to get a build for deployment was copying environment.prod.ts
file contents to environment.ts
.
I am no expert and I don't know what's happening behind the scenes when I add the --prod
flag to ng build
but I can at least say it doesn't build.
Closing as outdated.
Angular: 7.2.9
Firebase: 5.8.6
AngularFire: 5.1.2
How to reproduce these conditions
Steps to set up and reproduce
1) I had set up the following setting in my app.module to avoid timestampInSnapshot warning:
2) Updated @angular/fire to 5.1.2 from 5.1.1
3) Removed the following setting from my app.module
4) Deployed application to firebase hosting. Some chunk files were not loading, breaking the application.
Expected behavior
The absence of "{provide: FirestoreSettingsToken, useValue: {}}" from app.module should not break application.
Actual behavior
After update to @angular/fire 5.1.2 and removing {provide: FirestoreSettingsToken, useValue:{}} from app.module => providers breaks application in production. In development environment, app works normally.