Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Using firestorm with angular #10

Open
Monstrofil opened this issue Dec 3, 2019 · 2 comments
Open

Using firestorm with angular #10

Monstrofil opened this issue Dec 3, 2019 · 2 comments

Comments

@Monstrofil
Copy link
Contributor

Monstrofil commented Dec 3, 2019

I'm trying to use firestorm in angular project, but have unexpected issue related to di (probably).

The thing is that something imports GeoPoint.js before I actually instantiate firebase library (despite the fact that I do that even BEFORE any imports in main.ts):

core.js:4002 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'GeoPoint' of undefined
TypeError: Cannot read property 'GeoPoint' of undefined
    at new GeoPoint (GeoPoint.js:10)

The following patch solves the issue, and everything works fine.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
- var app_1 = require("firebase/app");
+ var app_1 = require("firebase");
/**
 * Wrapper for firestore geopoint class, mainly used to keep
 * imports clean when using the library.
 */
var GeoPoint = /** @class */ (function () {
    function GeoPoint(latitude, longitude) {
        this._native = new app_1.firestore.GeoPoint(latitude, longitude);

You can try this yourself:
https://stackblitz.com/edit/angular-kspirb?file=src%2Fapp%2Fapp.module.ts

Probably anyone knows any workarounds or can approve that changing require() to 'firebase' is ok and I can make pull request with this change?

@ight-reco
Copy link

ight-reco commented Dec 6, 2019

I'm facing this issue too. (It's Timestamp and Vue.js in my case though).

I think it's preferred that we stay hold require('firebase/app') and add require('firebase/firestore').
I guess that require('firebase') might outputs warnings like this: https://stackoverflow.com/questions/50707211/warning-it-looks-like-youre-using-the-development-build-of-the-firebase-js-sdk.

@vdiaz1130
Copy link

Any example of configuring FireStorm with AngularFire? I'm initializing Firebase as follows:
@NgModule({ declarations: [AppComponent], imports: [ ... AngularFireModule.initializeApp(environment.firebase), ... ]} );

Have not come across examples on how to go about it with Angular.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants