From 00dbfcfd334448b61dcd801de0b3f23027411d77 Mon Sep 17 00:00:00 2001 From: Feiyang1 Date: Tue, 21 May 2019 10:40:43 -0700 Subject: [PATCH 1/2] use default import for firebase --- src/firestore/firestore.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/firestore/firestore.ts b/src/firestore/firestore.ts index 7a912b667..04653fe29 100644 --- a/src/firestore/firestore.ts +++ b/src/firestore/firestore.ts @@ -9,7 +9,9 @@ import { AngularFirestoreCollection } from './collection/collection'; import { FirebaseFirestore, FirebaseOptions, FirebaseAppConfig, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire'; import { isPlatformServer } from '@angular/common'; -import { firestore, SDK_VERSION } from 'firebase/app'; +//Workaround for Nodejs build +//@ts-ignore +import firebase from 'firebase/app'; /** * The value of this token determines whether or not the firestore will have persistance enabled @@ -19,8 +21,8 @@ export const PersistenceSettingsToken = new InjectionToken('angularfire2.firestore.settings'); // timestampsInSnapshots was depreciated in 5.8.0 -const major = parseInt(SDK_VERSION.split('.')[0]); -const minor = parseInt(SDK_VERSION.split('.')[1]); +const major = parseInt(firebase.SDK_VERSION.split('.')[0]); +const minor = parseInt(firebase.SDK_VERSION.split('.')[1]); export const DefaultFirestoreSettings = ((major < 5 || (major == 5 && minor < 8)) ? {timestampsInSnapshots: true} : {}) as Settings; /** From f86ccad93638cc917fc53d490270328d7755bf6f Mon Sep 17 00:00:00 2001 From: James Daniels Date: Tue, 21 May 2019 13:18:33 -0700 Subject: [PATCH 2/2] Fix for the ng6 production build test We can't implicitly use the firestore type (i.e, the injection tokens) as typescript will compile this into a dynamic import in our d.ts & will break ng 6 users who are still on older versions. --- src/firestore/firestore.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/firestore/firestore.ts b/src/firestore/firestore.ts index 04653fe29..3b7ff7e4b 100644 --- a/src/firestore/firestore.ts +++ b/src/firestore/firestore.ts @@ -9,10 +9,13 @@ import { AngularFirestoreCollection } from './collection/collection'; import { FirebaseFirestore, FirebaseOptions, FirebaseAppConfig, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire'; import { isPlatformServer } from '@angular/common'; -//Workaround for Nodejs build -//@ts-ignore +// Workaround for Nodejs build +// @ts-ignore import firebase from 'firebase/app'; +// SEMVER: have to import here while we target ng 6, as the version of typescript doesn't allow dynamic import of types +import { firestore } from 'firebase/app'; + /** * The value of this token determines whether or not the firestore will have persistance enabled */