-
-
Save mzgoddard/3758427 to your computer and use it in GitHub Desktop.
commonjs/amd boilerplate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// shamlessly stolen from lodash | |
/*global define:false*/ | |
;(function( window, undefined ) { | |
var freeExports = false; | |
// must be loaded first! | |
var has = window.has; | |
if ( typeof exports === 'object' ) { | |
freeExports = exports; | |
if ( has( 'global' ) ) { window = global; } | |
} | |
var defineModule = function( $$deps$$ ) { | |
var $$module$$ = function() {}; | |
return $$module$$; | |
}; | |
if ( has( 'amd' ) ) { | |
// define as an anonymous module | |
define([ '$$deps$$' ], defineModule ); | |
} | |
else if ( freeExports ) { | |
var $$deps$$ = require( '$$deps$$' ); | |
var $$module$$ = defineModule( $$deps$$ ); | |
// in Node.js or RingoJS v0.8.0+ | |
if ( typeof module === 'object' && module && module.exports === freeExports ) { | |
module.exports = $$module$$; | |
} | |
// in Narwhal or RingoJS v0.7.0- | |
else { | |
freeExports.$$module$$ = $$module$$; | |
} | |
} | |
else { | |
// in a browser or Rhino | |
window.$$module$$ = defineModule( window.$$deps$$ ); | |
} | |
}( this )); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has.add( 'global', function() { | |
return exports && typeof global === 'object' && global && global === global.global; | |
} ); | |
has.add( 'amd', function() { | |
return typeof define === 'function' && typeof define.amd === 'object' && define.amd; | |
} ); | |
has.add( '... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment