Skip to content

Commit

Permalink
Merge pull request #1333 from jrburke/register-amd
Browse files Browse the repository at this point in the history
Optionally registers as AMD module
  • Loading branch information
jashkenas committed Nov 7, 2013
2 parents 1aa309b + d12b5be commit 82f9350
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -1284,4 +1284,16 @@

});

// AMD registration happens at the end for compatibility with AMD loaders
// that may not enforce next-turn semantics on modules. Even though general
// practice for AMD registration is to be anonymous, underscore registers
// as a named module because, like jQuery, it is a base library that is
// popular enough to be bundled in a third party lib, but not be part of
// an AMD load request. Those cases could generate an error when an
// anonymous define() is called outside of a loader request.
if (typeof define === 'function' && define.amd) {
define('underscore', [], function() {
return _;
});
}
}).call(this);

0 comments on commit 82f9350

Please sign in to comment.