Created
September 16, 2015 12:14
-
-
Save mpneuried/c6f1a4274eb98a10c559 to your computer and use it in GitHub Desktop.
code to export a browser module by commonjs, amd or global-var
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
root = @ | |
MYMODULE = | |
foo: 42 | |
fizzy: -> | |
return "bubbele" | |
# Export the module | |
if typeof module isnt 'undefined' and module.exports | |
exports = module.exports = MYMODULE | |
else if typeof exports isnt 'undefined' | |
exports.MYMODULE = MYMODULE | |
else if typeof define is 'function' and typeof define.amd is 'object' and define.amd | |
define -> | |
return MYMODULE | |
return | |
else | |
root.MYMODULE = MYMODULE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment