Skip to content

Instantly share code, notes, and snippets.

@shashankduhan
Created December 11, 2016 04:40
Show Gist options
  • Select an option

  • Save shashankduhan/acceca7f49f0d2b0f200e8b0ddfaf6b5 to your computer and use it in GitHub Desktop.

Select an option

Save shashankduhan/acceca7f49f0d2b0f200e8b0ddfaf6b5 to your computer and use it in GitHub Desktop.
var mymodule = (function(){
"use strict";
//This is sample module for loading a module using require() function in webpack.
return {
init: function(){
//*************************************
//Initialize some global functions..
//If you want to load a library, write codes in here.
//*************************************
},
myfunction: function(){
alert('Cool');
},
myvariable: 123;
}
})();
//UMD Wrapper (github.com/umdjs/umd/blob/master/returnExports.js | @umdjs + @nason)
(function(root, factory) {
// AMD.
if (typeof define === 'function' && define.amd)
define([], factory);
// Node.
else if (typeof exports === 'object')
module.exports = factory();
// Browser global.
else
root.mymodule = factory();
}(this, function() { return mymodule; }));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment