documentcloud/backbone — Issue #684: Add support for registering Backbone as an AMD Module. 
Author: treasonx
Created: 2011-10-23 18:25:21+00:00
State: open

Underscore 1.2 will properly register itself as an AMD module if it detects an amd loader. If you load underscore 1.2 with an AMD loader and then try to load Backbone, Backbone will fail because underscore will not exist in the global scope.

Backbone should do a similar check and asynchronously load underscore as a dependency.

Prior to underscore 1.2 I would use underscore and backbone with RequireJS like so.

```javascript
define(['modile1', 'order!underscore', 'order!backbone'], function(Module1) {
//Do stuff here. Backbone and underscore would be global
});

Now if I do the following with underscore 1.2

```javascript
define(['modile1', 'order!underscore', 'order!backbone'], function(Module1, _, Backbone) {
//I can load underscore properly because it is amd aware but Backbone will fail
//due to underscore not being in the global scope
});

If Backbone was AMD aware like underscore we could just do the following

```javascript
define(['modile1', 'backbone'], function(Module1, Backbone) {
//Backbone loads properly and pulls in underscore as its dependency
});

I have modified [Backbone on my own branch](https://github.com/treasonx/backbone/tree/amd) to check for an AMD loader and load underscore 1.2 properly. Unit tests still pass.