Skip to content

Instantly share code, notes, and snippets.

@nonsensecreativity
Forked from tejacques/umd-module.js
Created June 12, 2017 09:57
Show Gist options
  • Save nonsensecreativity/4f72c5e7731233d839bcb741158037c9 to your computer and use it in GitHub Desktop.
Save nonsensecreativity/4f72c5e7731233d839bcb741158037c9 to your computer and use it in GitHub Desktop.
; (function (global, define) { define('module-name', function (require, exports, module) {
// CommonJS style code here
/*!
* UMD/AMD/Global context Module Loader wrapper
* based off https://gist.github.com/tejacques/202a8f2d198ddd54a409
*
* This wrapper will try to use a module loader with the
* following priority:
*
* 1.) AMD
* 2.) CommonJS
* 3.) Context Variable (this)
* - window in the browser
* - module.exports in node and browserify
*/
});})(
typeof window == 'object' ? window : global,
typeof define == 'function' && define.amd ? define : (function (context) {
'use strict';
return typeof module == 'object' ? function (name, factory) {
factory(require, exports, module);
}
: function (name, factory) {
var module = {
exports: {}
};
var require = function (n) {
if (n === 'jquery') {
n = 'jQuery';
}
return context[n];
};
factory(require, module.exports, module);
context[name] = module.exports;
};
})(this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment