Created
October 20, 2020 01:40
-
-
Save naturecodevoid/a64351bfe324e07888c4fd1d64f4aa88 to your computer and use it in GitHub Desktop.
A simple universal module loader (based on https://github.com/TalAter/annyang/blob/master/dist/annyang.js#L13)
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
const library = {}; | |
{ | |
if (typeof define === "function" && define.amd) { | |
// AMD | |
define([], function () { | |
return library; | |
}); | |
} | |
if (typeof module === "object" && module.exports) { | |
// CommonJS | |
module.exports = library; | |
} | |
if (typeof global === "object") { | |
global.library = library; | |
} | |
if (typeof window === "object") { | |
window.library = library; | |
} | |
} | |
// Minified version: | |
"function"==typeof define&&define.amd&&define([],(function(){return library})),"object"==typeof module&&module.exports&&(module.exports=library),"object"==typeof global&&(global.library=library),"object"==typeof window&&(window.library=library); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment