Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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