Index: templates/modules.js.tmpl |
diff --git a/templates/modules.js.tmpl b/templates/modules.js.tmpl |
index c826d892704589d344ecb9fadb61348ab8448b3b..ace95f66133767c516ae0e2218ce3f565e9c7348 100644 |
--- a/templates/modules.js.tmpl |
+++ b/templates/modules.js.tmpl |
@@ -1,4 +1,18 @@ |
{%- if args["module"] -%} |
+if (!("require" in window)) |
Sebastian Noack
2017/03/31 10:42:01
The assumption of the global object being "window"
kzar
2017/03/31 14:03:01
Done.
|
+{ |
+ window.require = function(module) |
+ { |
+ if (!(module in require.scopes)) |
+ { |
+ let scope = {exports: {}}; |
+ require.scopes[module] = require.modules[module](scope, scope.exports); |
+ } |
+ return require.scopes[module]; |
+ } |
+ require.modules = Object.create(null); |
+ require.scopes = Object.create(null); |
+} |
{%- for module_name, script in modules -%} |
require.modules[{{ module_name|json }}] = function(module, exports) |
{ |