Skip to content

Commit

Permalink
Optionally registers as AMD module
Browse files Browse the repository at this point in the history
  • Loading branch information
jrburke committed Nov 6, 2013
1 parent 1aa309b commit d12b5be
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions underscore.js
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 d12b5be

Please sign in to comment.