Skip to content

Instantly share code, notes, and snippets.

@mattmccray
Last active December 25, 2015 22:39
Show Gist options
  • Select an option

  • Save mattmccray/7051748 to your computer and use it in GitHub Desktop.

Select an option

Save mattmccray/7051748 to your computer and use it in GitHub Desktop.
Support js modules in: browsers, web workers, and commonjs (node) environments in one line of code!
MyModule= {} # Whatever
# Magic export
@MyModule= (@module or module or {}).exports= MyModule
(function() {
var MyModule={ /* Whatever */ };
// Magic export
this.MyModule= (this.module || module || {}).exports= MyModule;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment