documentcloud/backbone — Issue #777: Require.js support
Author: JKrems
Created: 2011-12-09 11:42:27+00:00
State: open

Underscore.js does it - and Backbone can, too. It's not *very* pretty but I wanted to keep the changes to a minimum:

```javascript
(function(){ var bb_fn=(function(_){
...
var Backbone;
if (typeof exports !== 'undefined') {
Backbone = exports;
} else if (typeof define === 'function' && define.amd) {
// Register as a named module with AMD.
Backbone = {};
} else {
Backbone = root.Backbone = {};
}
...
return Backbone;
});
if (typeof define === 'function' && define.amd) {
var root = this;
define(['underscore'], function(_) {
return bb_fn.call(root, _);
});
} else {
bb_fn.call(this);
}
}).call(this);
´´´

What do you think?