Skip to content

Instantly share code, notes, and snippets.

@bspingarn
Last active December 18, 2015 22:08
Show Gist options
  • Save bspingarn/5852127 to your computer and use it in GitHub Desktop.
Save bspingarn/5852127 to your computer and use it in GitHub Desktop.
A simple function for returning RequireJS modules and namespacing them onto the window object for further interaction.
function exposeMod(moduleName){
var reqObject = require(moduleName);
if (moduleName.indexOf('/') ) {
moduleNameArray = moduleName.split('/');
window[moduleNameArray[moduleNameArray.length-1]] = reqObject;
}
else {
window[moduleName] = reqObject;
}
return reqObject;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment