I see JS libraries using these two different implementations. Only difference is the CommonJS line.
Are they functionally the same? Is assigning the value to module.exports not required?
/* 1: Assignment to module.exports */
(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: Doesn't assign to module.exports */
(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; };
}));