firebase npm package is not useable with browserify

1,055 views
Skip to first unread message

nat...@bugherd.com

unread,
Aug 1, 2014, 8:48:36 PM8/1/14
to fireba...@googlegroups.com
It would be nice if I could use the firebase package on npm with browserify the same way other packages work (react for instance).
This would make it very easy to create isomorphic apps with the firebase npm package.

Jacob Wenger

unread,
Aug 2, 2014, 10:45:20 PM8/2/14
to fireba...@googlegroups.com
Hey there,

Thanks for the suggestion. While we do provide an npm version of Firebase, it is for Node.js, not for use in browserify. So you are correct and we will talk internally about making our libraries more easily consumed via browserify.

In the meantime, I do have a few suggestions for you (note that I have never used browserify before so ignore any of these suggestions if they are plain incorrect):
Again, I am not a browserify user, but hopefully one of these things gives you a workaround until we get things set up with browserify. If you came up with a workaround, please share it here so everyone can benefit.

Thank you and good luck,
Jacob

John Nilsson

unread,
Aug 3, 2014, 9:31:54 AM8/3/14
to fireba...@googlegroups.com
+1 on npm packages for browserify. Also consider simple-login.

OTOH I'm probably going to switch to webpack to get some live editing going ( http://gaearon.github.io/react-hot-loader/ ). Since webpack can basically replace browserify maybe there are some shortcuts for you in that direction.


For now this is what I do:

index.html
<body>
    <script src='https://cdn.firebase.com/js/client/1.0.17/firebase.js' defer></script>
    <script src="browser-bundle.js" defer></script>
</body>


package.json
"devDependencies": {
  "browserify-shim": "^3.6.0"
},
"browserify": {
  "transform": [
    "browserify-shim"
  ]
},
"browserify-shim": {
  "firebase": "global:Firebase",
  "firebase-simple-login": "global:FirebaseSimpleLogin"
}

BR,
John


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jacob Wenger

unread,
Aug 21, 2014, 8:48:18 PM8/21/14
to fireba...@googlegroups.com
Hey everybody,

We just pushed version 1.0.21 of the Firebase npm module which now includes support for browserify. You should be able to just do npm install firebase (make sure you get version 1.0.21 or later) and then require("firebase") and browserify will work. No hacks required!

We will work on giving Simple Login the same treatment. 

Jacob
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

Keith Garrod

unread,
May 6, 2015, 12:57:56 PM5/6/15
to fireba...@googlegroups.com
Does anybody have a config for Firebase for webpack? I guess it shouldn't be difficult if it works in browserify, but I can't seem to get it working. 

What I have done so far is: 
providePlugin = new webpack.ProvidePlugin({
    _: "lodash",
    Firebase: "Firebase"
  })
and 
  alias: {
      Firebase: 'firebase/lib/firebase-web.js',

When I try to use Firebase (new Firebase(valid_firebase_url)) I get an error:

TypeError: object is not a function.

Michael Lehenbauer

unread,
May 6, 2015, 1:59:35 PM5/6/15
to fireba...@googlegroups.com
What do you get if you console.log(Firebase)?  If it's an object, I'm curious to see what its properties are.  I don't know much about webpack, but it seems like it should work with the firebase-web.js version.

-Michael

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Keith Garrod

unread,
May 6, 2015, 2:30:23 PM5/6/15
to fireba...@googlegroups.com

Hi Michael,

Thanks, I'll have a look in the morning. Do you have an example with Browserify? It should work more or less the same.

Best,

Keith


You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/P7wjSt8WA7Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Michael Lehenbauer

unread,
May 6, 2015, 2:49:11 PM5/6/15
to fireba...@googlegroups.com
Well, with browserify you'd just do:

npm install firebase

Then create a JS file that uses it, e.g. main.js:

var Firebase = require('firebase');
var ref = new Firebase('https://mike.firebaseio-demo.com');
ref.set('Hello world!');

And then run "browserify main.js -o bundle.js"

And now bundle.js will be a standalone JS file you can include in your HTML or whatever.

-Michael

Keith Garrod

unread,
May 6, 2015, 2:56:33 PM5/6/15
to fireba...@googlegroups.com

Thanks. I tried something very similar with webpack but it didn't work for me. I'll try again tomorrow.

Best,

Keith


Amardeep Singh-Sibia

unread,
May 25, 2016, 10:21:19 AM5/25/16
to Firebase Google Group
Hi Keith,

did you get it to work with webpack? Have you tried v3.0.0 of Firebase?

Best,

Amar

Jacob Wenger

unread,
May 25, 2016, 9:58:18 PM5/25/16
to fireba...@googlegroups.com
The new 3.x.x should be compatible with both Browserify and webpack. We need to get them into the docs though! For now, see this other thread.

Jacob

Reply all
Reply to author
Forward
0 new messages