Skip to content

Commit 8a33826

Browse files
Feiyang1jamesdaniels
authored andcommitted
fix(afs): Fix for builds targeting Node (#2079)
Use default import for firebase & ts-ignore, again the Node.js vs browser exports/typings biting us
1 parent d12b4c5 commit 8a33826

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/firestore/firestore.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import { AngularFirestoreCollection } from './collection/collection';
99
import { FirebaseFirestore, FirebaseOptions, FirebaseAppConfig, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';
1010
import { isPlatformServer } from '@angular/common';
1111

12-
import { firestore, SDK_VERSION } from 'firebase/app';
12+
// Workaround for Nodejs build
13+
// @ts-ignore
14+
import firebase from 'firebase/app';
15+
16+
// SEMVER: have to import here while we target ng 6, as the version of typescript doesn't allow dynamic import of types
17+
import { firestore } from 'firebase/app';
1318

1419
/**
1520
* The value of this token determines whether or not the firestore will have persistance enabled
@@ -19,8 +24,8 @@ export const PersistenceSettingsToken = new InjectionToken<PersistenceSettings|u
1924
export const FirestoreSettingsToken = new InjectionToken<Settings>('angularfire2.firestore.settings');
2025

2126
// timestampsInSnapshots was depreciated in 5.8.0
22-
const major = parseInt(SDK_VERSION.split('.')[0]);
23-
const minor = parseInt(SDK_VERSION.split('.')[1]);
27+
const major = parseInt(firebase.SDK_VERSION.split('.')[0]);
28+
const minor = parseInt(firebase.SDK_VERSION.split('.')[1]);
2429
export const DefaultFirestoreSettings = ((major < 5 || (major == 5 && minor < 8)) ? {timestampsInSnapshots: true} : {}) as Settings;
2530

2631
/**

0 commit comments

Comments
 (0)