noveogroup / backbone.iobind

Bind socket.io events to backbone models & collections. Also includes a drop-in replacement for Backbone.sync using socket.io.
https://noveogroup.github.io/backbone.iobind/
582 stars 65 forks source link

Add define() to UMD to make proper AMD package #40

Closed tony closed 11 years ago

tony commented 11 years ago

Hi, this may not be the best, but I had to manually do this to get backbone.iobind to play nice with AMD. Requirejs is picky about seeing define.

Backbone UMD pattern taken from: https://github.com/thedersen/backbone.validation/blob/master/dist/backbone-validation-amd.js

With no define() I encounter the error:

Uncaught Error: Module name "backbone.<moduleName>" has not been loaded yet for context: _. Use require([])

mahnunchik commented 11 years ago

These changes broke compatibility with other "require" systems.

tony commented 11 years ago

@mahnunchik

I need this to work, so I'm willing to keep swinging at it.

What require libraries need to be tested against in addition to requirejs and almond?

mahnunchik commented 11 years ago

The library should support: 1) CommonJS (for example browserify in browsers) 2) exporting to global Backbone object (window.Backbone)

Tests of different "require" would be very useful

tony commented 11 years ago

I have too much on my plate atm, I'm going to close PR in case someone else has the time to test UMD thoroughly.

ghost commented 11 years ago

What is the solution to this? Currently I can't use this for production as the combined js result throws this error.

temp3l commented 10 years ago

uff, nobody got a solution yet? or a hack ? ;)