googlearchive / backbonefire

Backbone bindings for Firebase
https://backbonefire.firebaseapp.com
MIT License
291 stars 77 forks source link

Provide CommonJS support #69

Open mulderp opened 10 years ago

mulderp commented 10 years ago

Hi!

Until recently, I was using this shim to run Backfire with CommonJS support: https://github.com/cloud-walker/client-backfire

Unfortunately, the project has been deprecated. Any option to have CommonJS support built in in Backfire?

That would help running small Browserify projects like these: https://github.com/pipefishbook/pipefishbook.github.io

Thanks!

katowulf commented 10 years ago

Here was an initial approach at integrating this (also in the closed pull request): https://gist.github.com/katowulf/acd0b51b740782f1851e

The difficulty is that if we inject require('firebase'), the factory resolved the server NPM module 'firebase' (see https://www.npmjs.org/package/firebase ), what we would need is the client-side version of firebase (see https://www.npmjs.org/package/client-firebase ).

This means, if we inject:

 require('client-firebase')

everything works great.

Here is @mulderp's working example: https://github.com/mulderp/debug/blob/master/app/main.js

All in all it would be awesome, if one would just have to do:

 $ npm install backfire

then, in a file main.js:

var Backfire = require('backfire')

And have e.g. Backbone.Backfire.Collection({ firebase: 'someUrl' })

chuangbo commented 9 years ago

+1

bricejlin commented 9 years ago

+1!!

ChetHarrison commented 9 years ago

Hey all. I just added the UMD wrapper in a PR. Once they merge it It should work with requirejs and commonjs as well as the global.

mbrevda commented 8 years ago

PR in https://github.com/firebase/backbonefire/pull/147