Skip to content

Instantly share code, notes, and snippets.

@ben-ekw
Created May 24, 2023 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ben-ekw/82a117294ece4b55b49766be31927018 to your computer and use it in GitHub Desktop.
Save ben-ekw/82a117294ece4b55b49766be31927018 to your computer and use it in GitHub Desktop.
Ultimate UMD boilerplate template -- combines returnExports and fid-umd (replace "changeme" with your module name)
(function (name, root, factory) {
if (typeof define === "function" && define.amd) {
// AMD
define([], factory);
} else if (typeof module === "object" && module.exports) {
// Node
module.exports = factory();
} else if (typeof exports === "object") {
// CommonJS
exports[name] = factory();
} else if (typeof modulejs === "object") {
// modulejs
modulejs.define(name, factory);
} else if (typeof YUI === "object") {
// YUI
YUI.add(name, function (Y) {
Y[name] = factory();
});
} else {
// browser globals
root[name] = factory();
}
})("changeme", typeof self !== "undefined" ? self : this, function () {
"use strict";
// Methods
function notHelloOrGoodbye() {
return "private";
}
function hello() {
return "hello";
}
function goodbye() {
return "goodbye";
}
// Expose public methods
return {
hello: hello,
goodbye: goodbye,
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment