Skip to content

Instantly share code, notes, and snippets.

@mpneuried
Created September 16, 2015 12:14
Show Gist options
  • Save mpneuried/c6f1a4274eb98a10c559 to your computer and use it in GitHub Desktop.
Save mpneuried/c6f1a4274eb98a10c559 to your computer and use it in GitHub Desktop.
code to export a browser module by commonjs, amd or global-var
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