Skip to content

Instantly share code, notes, and snippets.

@robflaherty
Created April 28, 2016 17:55
Show Gist options
  • Save robflaherty/1e734234d55f39bc3e151ce3afeac899 to your computer and use it in GitHub Desktop.
Save robflaherty/1e734234d55f39bc3e151ce3afeac899 to your computer and use it in GitHub Desktop.
UMD
/* 1 */
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS
module.exports = factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function($) {
$.fn.jqueryPlugin = function () { return true; };
}));
/* 2 */
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function($) {
$.fn.jqueryPlugin = function () { return true; };
}));
@robflaherty
Copy link
Author

module.exports = factory(require('jquery'));
vs
factory(require('jquery'));

Are these functionally the same? Is assigning to module.exports redundant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment