Using AngularFire in an Angular 7 library

292 views
Skip to first unread message

ty.sh...@gmail.com

unread,
Mar 18, 2019, 12:34:49 AM3/18/19
to Firebase Google Group
Is is possible to use AngularFire in an Angular 7 library? I would like to use a common data service across all my projects, however when I created the library then started importing AngularFire Modules, the below highlighted lines has me scratching my head.

import { NgModule } from '@angular/core';

// Angular
import { AngularFireModule } from '@angular/fire';
import { AngularFireDatabaseModule } from '@angular/fire/database';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { environment } from '../../environments/environment';
 

@NgModule({
  declarations: [],
  imports: [
    AngularFireModule.initializeApp(firebaseConfig),
  ],
  exports: [
    AngularFireAuthModule,
    AngularFireDatabaseModule,
    AngularFireModule,
  ]
})
export class SixteenCoreModule { }

How exactly would I implement an environment in the new Angular 7, when the library has no environment file? Better yet, how would I use AngularFire in a library?

Kato Richardson

unread,
Mar 18, 2019, 11:30:06 AM3/18/19
to Firebase Google Group
An environment file is nothing special. Feel free to create one or just manually create the object and pass it into initializeApp().




--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/118713af-f5ff-48fd-a8c7-39c2eba4cc20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

ty.sh...@gmail.com

unread,
Mar 18, 2019, 3:14:10 PM3/18/19
to Firebase Google Group
Thanks for the reply.

OK, I wasn't sure with the library capabilities if there was something else I needed to worry about. I'll try that out, create my own file/s, and see how it works.

Kato Richardson

unread,
Mar 18, 2019, 4:30:59 PM3/18/19
to Firebase Google Group
Performing a cursory scan of the issue tracker, it doesn't look like anyone has reported incompatibilities with 7 yet. So you should be fine.

☼, Kato


For more options, visit https://groups.google.com/d/optout.

ty.sh...@gmail.com

unread,
Mar 18, 2019, 11:56:13 PM3/18/19
to Firebase Google Group
FYI: When I added the environments.ts file I got the following build 

Distributing npm packages with 'dependencies' is not recommended. Please consider adding @angular/fire to 'peerDependencies' or remove it from 'dependencies'.

BUILD ERROR
Dependency @angular/fire must be explicitly whitelisted.
Error: Dependency @angular/fire must be explicitly whitelisted.

Hence this goes to my original question can you use AngularFire in a library?
Reply all
Reply to author
Forward
0 new messages