Skip to content

docs(): using default firebase/app exports #1851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 6, 2018
2 changes: 1 addition & 1 deletion docs/ionic/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ at `login.service.ts` add this function:
```ts

import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import firebase from 'firebase/app';
import AuthProvider = firebase.auth.AuthProvider;

export class AuthService {
Expand Down
4 changes: 2 additions & 2 deletions docs/ionic/v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import { AngularFireAuth } from 'AngularFire/auth';
// Do not import from 'firebase' as you'll lose the tree shaking benefits
import * as firebase from 'firebase/app';
import firebase from 'firebase/app';

@Injectable()
export class AuthService {
Expand Down Expand Up @@ -467,7 +467,7 @@ import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import { AngularFireAuth } from 'AngularFire/auth';
// Do not import from 'firebase' as you'll lose the tree shaking benefits
import * as firebase from 'firebase/app';
import firebase from 'firebase/app';

import { Platform } from 'ionic-angular';
import { Facebook } from 'ionic-native';
Expand Down
6 changes: 3 additions & 3 deletions docs/ionic/v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import firebase from 'firebase/app';

@Component({
selector: 'page-home',
Expand Down Expand Up @@ -423,7 +423,7 @@ import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import firebase from 'firebase/app';

@Component({
selector: 'page-home',
Expand Down Expand Up @@ -581,7 +581,7 @@ import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import firebase from 'firebase/app';

import { Platform } from 'ionic-angular';
import { Facebook } from '@ionic-native/facebook';
Expand Down
4 changes: 2 additions & 2 deletions docs/version-4-upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ In 4.0 we've reduced the complexity of the auth module by providing only [`fireb
```typescript
import { AngularFireAuth } from 'angularfire2/auth';
// Do not import from 'firebase' as you'd lose the tree shaking benefits
import * as firebase from 'firebase/app';
import firebase from 'firebase/app';
...

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

// Do not import from 'firebase' as you'd lose the tree shaking benefits
import * as firebase from 'firebase/app';
import firebase from 'firebase/app';


@NgModule({
Expand Down
1 change: 0 additions & 1 deletion src/auth/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { User } from 'firebase';
import { ReflectiveInjector, Provider } from '@angular/core';
import { Observable, Subject } from 'rxjs'
import { TestBed, inject } from '@angular/core/testing';
import { FirebaseApp, FirebaseOptionsToken, AngularFireModule, FirebaseNameOrConfigToken } from 'angularfire2';
Expand Down
1 change: 0 additions & 1 deletion src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Injectable, Inject, Optional, NgZone, PLATFORM_ID } from '@angular/core
import { Observable, of, from } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { FirebaseAppConfig, FirebaseOptions } from 'angularfire2';

import { User, auth } from 'firebase';

import { FirebaseAuth, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from 'angularfire2';
Expand Down
5 changes: 2 additions & 3 deletions src/core/angularfire2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

import { TestBed, inject, withModule, async } from '@angular/core/testing';
import { ReflectiveInjector, Provider, PlatformRef, NgModule, Compiler, ApplicationRef, CompilerFactory } from '@angular/core';
import { TestBed, inject } from '@angular/core/testing';
import { PlatformRef, NgModule, CompilerFactory } from '@angular/core';
import { FirebaseApp, AngularFireModule } from 'angularfire2';
import { Subscription } from 'rxjs';
import { COMMON_CONFIG } from './test-config';
Expand Down
12 changes: 7 additions & 5 deletions src/core/firebase.app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InjectionToken, NgZone, NgModule, Optional } from '@angular/core';
import { app, auth, database, firestore, functions, messaging, storage } from 'firebase';
// @ts-ignore
import { InjectionToken, NgModule, Optional } from '@angular/core';
import {app, auth, database, firestore, functions, messaging, storage } from 'firebase';
// @ts-ignore (https://github.com/firebase/firebase-js-sdk/pull/1206)
import firebase from 'firebase/app';

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

const FirebaseAppProvider = {
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/collection/collection.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Observable, from } from 'rxjs';
import { fromCollectionRef } from '../observable/fromRef';
import { map, filter, scan } from 'rxjs/operators';
import { firestore } from 'firebase/app';
import { firestore } from 'firebase';

import { DocumentChangeType, CollectionReference, Query, DocumentReference, DocumentData, DocumentChangeAction } from '../interfaces';
import { docChanges, sortedChanges } from './changes';
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/document/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { map } from 'rxjs/operators';

import { AngularFirestore, associateQuery } from '../firestore';
import { AngularFirestoreCollection } from '../collection/collection';
import { firestore } from 'firebase/app';
import { firestore } from 'firebase';
import { runInZone } from 'angularfire2';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { InjectionToken, NgZone, PLATFORM_ID, Injectable, Inject, Optional } fro

import { Observable, of, from } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { firestore } from 'firebase/app';
import { firestore } from 'firebase';

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