Index: templates/modules.js.tmpl |
diff --git a/templates/modules.js.tmpl b/templates/modules.js.tmpl |
index c826d892704589d344ecb9fadb61348ab8448b3b..39f3bd302e8e0f10d4badd3d5e61e94dd0a4dd68 100644 |
--- a/templates/modules.js.tmpl |
+++ b/templates/modules.js.tmpl |
@@ -1,4 +1,31 @@ |
{%- if args["module"] -%} |
+if (typeof require != "function") |
kzar
2017/04/01 01:32:57
As discussed in IRC this is safer, since if a webp
Sebastian Noack
2017/04/01 10:02:56
Wow, I never noticed that named elements become au
|
+{ |
+ var 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); |
+} |
+ |
+{% if args["injectinfomodule"] %} |
+require.modules["info"] = function(module, exports) |
+{ |
+{% if type == "gecko-webext" %} |
+{% include "geckoInfo.js.tmpl" %} |
+{% elif type == "chrome" or type == "edge" %} |
+{% include "chromeInfo.js.tmpl" %} |
+{% endif %} |
+return module.exports; |
+}; |
+{% endif %} |
+ |
{%- for module_name, script in modules -%} |
require.modules[{{ module_name|json }}] = function(module, exports) |
{ |