Created
July 29, 2013 10:15
-
-
Save pid/6103387 to your computer and use it in GitHub Desktop.
Adding AMD into the mix and don't forget CommonJS
This file contains hidden or 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
| /* Thanks to http://oli.me.uk/2013/07/21/exporting-through-amd-commonjs-and-the-global-object/ */ | |
| (function () { | |
| // YOUR ORIGINAL CODE HERE | |
| if (typeof define === 'function' && define.amd) { | |
| define(function () { | |
| return Foo; | |
| }); | |
| } | |
| else if (typeof module !== 'undefined' && module.exports) { | |
| module.exports = Foo; | |
| // Or maybe: module.exports.Foo = Foo; | |
| // It's up to you really. | |
| } | |
| else { | |
| this.Foo = Foo; | |
| } | |
| }.call(this)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment