Created
February 23, 2018 16:08
-
-
Save steveosoule/890a672dcfe07be56d3b866fb1ab90d0 to your computer and use it in GitHub Desktop.
UMD Sample JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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