Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Created February 23, 2018 16:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveosoule/890a672dcfe07be56d3b866fb1ab90d0 to your computer and use it in GitHub Desktop.
Save steveosoule/890a672dcfe07be56d3b866fb1ab90d0 to your computer and use it in GitHub Desktop.
UMD Sample JS
// https://github.com/umdjs/umd
// https://css-tricks.com/gotchas-publishing-modules-npm-bower/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['dependency'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require('dependency'));
} else {
// Browser globals (root is window)
root.returnExports = factory(root.dependency);
}
}(this, function (dependency) {
// Use dependency in some fashion.
return {
// Your module goes here
};
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment