Firebase with EnyoJS

Hi there! Have you gusy ever used Firebase with enyojs ? I'm just trying to set up the library but I'm getting the following issue.
When I import the firebase library (or at least I try), I get the next error: TypeError: firebase.initializeApp is not a function in the chrome inspector. Here is my code:
var firebase = require('../../node_modules/firebase/firebase'); var app = firebase.initializeApp(config);

Any idea about what am I doing wrong ? Thanks!

Comments

  • Thanks to @sugardave to help me find a solution! If someone comes to face this kind of issue anytime this is what I did to solve it:

    Firs you have to download the library 'firebase.js' (https://www.gstatic.com/firebasejs/4.3.0/firebase.js).
    Then you have to add it to the headScripts list on .enyoconfig file:
    "headScripts": [ "path/to/firebase.js" ],

    Instead of that, you could also use the --head-scripts parameter when packing the app. Like this:
    enyo pack path/to/app --head-scripts=path/to/firebase.js

    Now, on index.js file, you have to pass an object with the firebase reference when creating an App instance. So, in my case, my index.js file is as follows:
    var ready = require('enyo/ready'), App = require('./src/App'); ready(function () { new App({firebase: firebase}); });

    And that's it!! Now you can call firebase from any of your component files and make realtime database operations or whatever you want to try with Firebase.
  • Just a note to say that it may now be unnecessary to pass that firebase reference to the app, since firebase.js will make a global firebase namespace.

    Good luck!
Sign In or Register to comment.