Skip to content

Instantly share code, notes, and snippets.

@cybrown
Created July 8, 2013 20:44
Show Gist options
  • Select an option

  • Save cybrown/5952339 to your computer and use it in GitHub Desktop.

Select an option

Save cybrown/5952339 to your computer and use it in GitHub Desktop.
Require.js, nodejs and vanilla module definition (jQuery like).
;(function (window, undefined) { // undefined as an undefined parameter
'use strict';
var Module = null; // module definition here
if (typeof module === "object" && module && typeof module.exports === "object") {
module.exports = Module; // commonjs module (ndoejs...)
} else if (typeof define === "function" && define.amd) {
define([], function () {return Module;}); // amd module (requirejs...)
} else if (typeof window === "object" && typeof window.document === "object") {
window.Module = Module; // Browser global namespace
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment