Created
March 26, 2012 15:54
-
-
Save tkellen/2206123 to your computer and use it in GitHub Desktop.
requirejs library for node and browser with and without amd
This file contains 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
(function(global, define) { | |
var loader = false; | |
// detect if there is an amd loader on the global namespace | |
if(typeof global.define === 'function') { | |
loader=true; | |
} | |
{{ALMOND_SHIMMED_LIBRARY}} | |
if(typeof module !== 'undefined' && module.exports) { | |
// export library for node | |
module.exports = require('library'); | |
} else if(loader === true) { | |
// define library for global amd loader that is already present on page | |
global.define('library',[],function(){return require('library');}); | |
} else { | |
// define library on global namespace for inline script loading | |
global['library'] = require('library'); | |
} | |
}(this)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This makes this an anonymous module that can be found by tools like the r.js optimizer to insert the right name.