Created
July 10, 2017 03:19
-
-
Save Yuffster/2a0e3df141816a7419b617a0fc5b057a to your computer and use it in GitHub Desktop.
require.js
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
// 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 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
/** | |
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