Skip to content

Instantly share code, notes, and snippets.

@DarkaOnLine
Created November 25, 2015 06:40
Show Gist options
  • Select an option

  • Save DarkaOnLine/0c6742fd12704d703136 to your computer and use it in GitHub Desktop.

Select an option

Save DarkaOnLine/0c6742fd12704d703136 to your computer and use it in GitHub Desktop.
Common js module boiler plate
(function (root, factory) {
if (typeof exports === 'object') {
// CommonJS
module.exports = factory(require('b'));
} else if (typeof define === 'function' && define.amd) {
// AMD
define(['b'], function (b) {
return (root.returnExportsGlobal = factory(b));
});
} else {
// Global Variables
root.returnExportsGlobal = factory(root.b);
}
}(this, function (b) {
// Your actual module
return {};
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment