Skip to content

Commit 396e762

Browse files
authored
docs(): using default firebase/app exports (angular#1851)
1 parent 185943f commit 396e762

File tree

11 files changed

+20
-21
lines changed

11 files changed

+20
-21
lines changed

docs/ionic/authentication.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ at `login.service.ts` add this function:
4747
```ts
4848

4949
import { AngularFireAuth } from 'angularfire2/auth';
50-
import * as firebase from 'firebase/app';
50+
import firebase from 'firebase/app';
5151
import AuthProvider = firebase.auth.AuthProvider;
5252

5353
export class AuthService {

docs/ionic/v2.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ import { Observable } from 'rxjs/Observable';
264264
import { Injectable } from '@angular/core';
265265
import { AngularFireAuth } from 'AngularFire/auth';
266266
// Do not import from 'firebase' as you'll lose the tree shaking benefits
267-
import * as firebase from 'firebase/app';
267+
import firebase from 'firebase/app';
268268

269269
@Injectable()
270270
export class AuthService {
@@ -467,7 +467,7 @@ import { Observable } from 'rxjs/Observable';
467467
import { Injectable } from '@angular/core';
468468
import { AngularFireAuth } from 'AngularFire/auth';
469469
// Do not import from 'firebase' as you'll lose the tree shaking benefits
470-
import * as firebase from 'firebase/app';
470+
import firebase from 'firebase/app';
471471

472472
import { Platform } from 'ionic-angular';
473473
import { Facebook } from 'ionic-native';

docs/ionic/v3.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ import { Component } from '@angular/core';
370370
import { NavController } from 'ionic-angular';
371371

372372
import { AngularFireAuth } from 'angularfire2/auth';
373-
import * as firebase from 'firebase/app';
373+
import firebase from 'firebase/app';
374374

375375
@Component({
376376
selector: 'page-home',
@@ -423,7 +423,7 @@ import { Component } from '@angular/core';
423423
import { NavController } from 'ionic-angular';
424424

425425
import { AngularFireAuth } from 'angularfire2/auth';
426-
import * as firebase from 'firebase/app';
426+
import firebase from 'firebase/app';
427427

428428
@Component({
429429
selector: 'page-home',
@@ -581,7 +581,7 @@ import { Component } from '@angular/core';
581581
import { NavController } from 'ionic-angular';
582582

583583
import { AngularFireAuth } from 'angularfire2/auth';
584-
import * as firebase from 'firebase/app';
584+
import firebase from 'firebase/app';
585585

586586
import { Platform } from 'ionic-angular';
587587
import { Facebook } from '@ionic-native/facebook';

docs/version-4-upgrade.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ In 4.0 we've reduced the complexity of the auth module by providing only [`fireb
3636
```typescript
3737
import { AngularFireAuth } from 'angularfire2/auth';
3838
// Do not import from 'firebase' as you'd lose the tree shaking benefits
39-
import * as firebase from 'firebase/app';
39+
import firebase from 'firebase/app';
4040
...
4141

4242
user: Observable<firebase.User>;
@@ -75,7 +75,7 @@ import { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth';
7575
import { environment } from '../environments/environment';
7676

7777
// Do not import from 'firebase' as you'd lose the tree shaking benefits
78-
import * as firebase from 'firebase/app';
78+
import firebase from 'firebase/app';
7979

8080

8181
@NgModule({

src/auth/auth.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { User } from 'firebase';
2-
import { ReflectiveInjector, Provider } from '@angular/core';
32
import { Observable, Subject } from 'rxjs'
43
import { TestBed, inject } from '@angular/core/testing';
54
import { FirebaseApp, FirebaseOptionsToken, AngularFireModule, FirebaseNameOrConfigToken } from 'angularfire2';

src/auth/auth.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Injectable, Inject, Optional, NgZone, PLATFORM_ID } from '@angular/core
22
import { Observable, of, from } from 'rxjs';
33
import { switchMap } from 'rxjs/operators';
44
import { FirebaseAppConfig, FirebaseOptions } from 'angularfire2';
5-
65
import { User, auth } from 'firebase';
76

87
import { FirebaseAuth, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from 'angularfire2';

src/core/angularfire2.spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
2-
import { TestBed, inject, withModule, async } from '@angular/core/testing';
3-
import { ReflectiveInjector, Provider, PlatformRef, NgModule, Compiler, ApplicationRef, CompilerFactory } from '@angular/core';
1+
import { TestBed, inject } from '@angular/core/testing';
2+
import { PlatformRef, NgModule, CompilerFactory } from '@angular/core';
43
import { FirebaseApp, AngularFireModule } from 'angularfire2';
54
import { Subscription } from 'rxjs';
65
import { COMMON_CONFIG } from './test-config';

src/core/firebase.app.module.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { InjectionToken, NgZone, NgModule, Optional } from '@angular/core';
2-
import { app, auth, database, firestore, functions, messaging, storage } from 'firebase';
3-
// @ts-ignore
1+
import { InjectionToken, NgModule, Optional } from '@angular/core';
2+
import {app, auth, database, firestore, functions, messaging, storage } from 'firebase';
3+
// @ts-ignore (https://github.com/firebase/firebase-js-sdk/pull/1206)
44
import firebase from 'firebase/app';
55

66
// Public types don't expose FirebaseOptions or FirebaseAppConfig
@@ -36,9 +36,11 @@ export function _firebaseAppFactory(options: FirebaseOptions, nameOrConfig?: str
3636
const name = typeof nameOrConfig === 'string' && nameOrConfig || '[DEFAULT]';
3737
const config = typeof nameOrConfig === 'object' && nameOrConfig || {};
3838
config.name = config.name || name;
39-
const existingApp = firebase.apps.filter(app => app && app.name === config.name)[0];
39+
// Added any due to some inconsistency between @firebase/app and firebase types
40+
const existingApp = firebase.apps.filter(app => app && app.name === config.name)[0] as any;
4041
// We support FirebaseConfig, initializeApp's public type only accepts string; need to cast as any
41-
return (existingApp || firebase.initializeApp(options, config)) as FirebaseApp;
42+
// Should be solved with https://github.com/firebase/firebase-js-sdk/pull/1206
43+
return (existingApp || firebase.initializeApp(options, config as any)) as FirebaseApp;
4244
}
4345

4446
const FirebaseAppProvider = {

src/firestore/collection/collection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Observable, from } from 'rxjs';
22
import { fromCollectionRef } from '../observable/fromRef';
33
import { map, filter, scan } from 'rxjs/operators';
4-
import { firestore } from 'firebase/app';
4+
import { firestore } from 'firebase';
55

66
import { DocumentChangeType, CollectionReference, Query, DocumentReference, DocumentData, DocumentChangeAction } from '../interfaces';
77
import { docChanges, sortedChanges } from './changes';

src/firestore/document/document.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { map } from 'rxjs/operators';
55

66
import { AngularFirestore, associateQuery } from '../firestore';
77
import { AngularFirestoreCollection } from '../collection/collection';
8-
import { firestore } from 'firebase/app';
8+
import { firestore } from 'firebase';
99
import { runInZone } from 'angularfire2';
1010

1111
/**

src/firestore/firestore.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { InjectionToken, NgZone, PLATFORM_ID, Injectable, Inject, Optional } fro
22

33
import { Observable, of, from } from 'rxjs';
44
import { catchError } from 'rxjs/operators';
5-
import { firestore } from 'firebase/app';
5+
import { firestore } from 'firebase';
66

77
import { Settings, CollectionReference, DocumentReference, QueryFn, AssociatedReference } from './interfaces';
88
import { AngularFirestoreDocument } from './document/document';

0 commit comments

Comments
 (0)