Skip to content

Instantly share code, notes, and snippets.

@Yuffster
Created July 10, 2017 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yuffster/2a0e3df141816a7419b617a0fc5b057a to your computer and use it in GitHub Desktop.
Save Yuffster/2a0e3df141816a7419b617a0fc5b057a to your computer and use it in GitHub Desktop.
require.js
// Global object to hold modules by their path names.
Modules = {};
Modules.__loaded__ = {};
// Give all the other scripts access to the module hierarchy.
function require(p) {
if (Modules.__loaded__[p]) {
// Only initialize each module once.
return Modules.__loaded__[p];
}
var mod = Modules[p];
if (!mod) throw "Module not found: "+p;
Modules.__loaded__[p] = mod() || true;
return require(p);
}
/**
This is the template we use to wrap our JavaScript modules.
It's never actually called directly; instead it's used to wrap the actual
module files into self-contained closures, which are attached to the
global Module object.
This file is packed so that module line numbers match returned line
numbers.
**/
Modules["{{ path }}"] = (function(){
var _e;
/**
Each module has access to a function called exports. Data passed to
this function will be returned from the globally defined require
function.
**/
function exports(a) { _e = a; }
(function() {
/* {{ code }} */
}());
return _e;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment