@@ -7,18 +7,7 @@ import FirebaseService from './firebase';
77import RSVP from 'rsvp' ;
88const { resolve } = RSVP ;
99
10- // TODO move these over to dynamic imports
11- import 'firebase/auth' ;
12- import 'firebase/database' ;
13- import 'firebase/firestore' ;
14- import 'firebase/functions' ;
15- import 'firebase/messaging' ;
16- import 'firebase/storage' ;
17-
18- // @ts -ignore
19- import { app , auth , database , firestore , functions , messaging , storage } from 'firebase/app' ;
20-
21- const getApp = ( service : FirebaseAppService ) : app . App => {
10+ const getApp = ( service : FirebaseAppService ) => {
2211 const firebase = get ( service , 'firebase' ) ;
2312 const name = get ( service , 'name' ) ;
2413 return firebase . app ( name ) ;
@@ -37,12 +26,16 @@ export default class FirebaseAppService extends Service.extend({
3726 options ?: object ;
3827
3928 delete = ( ) => getApp ( this ) . delete ( ) ;
40- auth = ( ) => resolve ( getApp ( this ) . auth ( ) ) ;
41- database = ( databaseURL ?: string ) => resolve ( getApp ( this ) . database ( databaseURL ) ) ;
42- firestore = ( ) => resolve ( getApp ( this ) . firestore ( ) ) ;
43- functions = ( region ?: string ) => resolve ( getApp ( this ) . functions ( region ) ) ;
44- messaging = ( ) => resolve ( getApp ( this ) . messaging ( ) ) ;
45- storage = ( storageBucket ?: string ) => resolve ( getApp ( this ) . storage ( storageBucket ) ) ;
29+
30+ auth = ( ) => resolve ( import ( 'firebase/auth' ) ) . then ( ( ) => getApp ( this ) . auth ( ) ) ;
31+ firestore = ( ) => resolve ( import ( 'firebase/firestore' ) ) . then ( ( ) => getApp ( this ) . firestore ( ) ) ;
32+ messaging = ( ) => resolve ( import ( 'firebase/messaging' ) ) . then ( ( ) => getApp ( this ) . messaging ( ) ) ;
33+ database = ( url ?: string ) => resolve ( import ( 'firebase/database' ) ) . then ( ( ) => getApp ( this ) . database ( url ) ) ;
34+ functions = ( region ?: string ) => resolve ( import ( 'firebase/functions' ) ) . then ( ( ) => getApp ( this ) . functions ( region ) ) ;
35+
36+ // TODO: drop the <any> once firebase-js-sdk #1792 and #1812 and patched in, they were missing typings
37+ performance = ( ) => resolve ( import ( < any > 'firebase/performance' ) ) . then ( ( ) => getApp ( this ) . performance ( ) ) ;
38+ storage = ( url ?: string ) => resolve ( import ( < any > 'firebase/storage' ) ) . then ( ( ) => getApp ( this ) . storage ( url ) ) ;
4639
4740 init ( ) {
4841 this . _super ( ...arguments ) ;
@@ -56,4 +49,4 @@ declare module '@ember/service' {
5649 interface Registry {
5750 "firebase-app" : FirebaseAppService ;
5851 }
59- }
52+ }
0 commit comments