| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 {%- if args["module"] -%} | 1 {%- if args["module"] -%} |
| 2 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
| |
| 3 { | |
| 4 var require = function(module) | |
| 5 { | |
| 6 if (!(module in require.scopes)) | |
| 7 { | |
| 8 let scope = {exports: {}}; | |
| 9 require.scopes[module] = require.modules[module](scope, scope.exports); | |
| 10 } | |
| 11 return require.scopes[module]; | |
| 12 }; | |
| 13 require.modules = Object.create(null); | |
| 14 require.scopes = Object.create(null); | |
| 15 } | |
| 16 | |
| 17 {% if args["injectinfomodule"] %} | |
| 18 require.modules["info"] = function(module, exports) | |
| 19 { | |
| 20 {% if type == "gecko-webext" %} | |
| 21 {% include "geckoInfo.js.tmpl" %} | |
| 22 {% elif type == "chrome" or type == "edge" %} | |
| 23 {% include "chromeInfo.js.tmpl" %} | |
| 24 {% endif %} | |
| 25 return module.exports; | |
| 26 }; | |
| 27 {% endif %} | |
| 28 | |
| 2 {%- for module_name, script in modules -%} | 29 {%- for module_name, script in modules -%} |
| 3 require.modules[{{ module_name|json }}] = function(module, exports) | 30 require.modules[{{ module_name|json }}] = function(module, exports) |
| 4 { | 31 { |
| 5 {{ script }} | 32 {{ script }} |
| 6 return module.exports; | 33 return module.exports; |
| 7 }; | 34 }; |
| 8 | 35 |
| 9 {% endfor -%} | 36 {% endfor -%} |
| 10 {%- set modules = dict(modules) -%} | 37 {%- set modules = dict(modules) -%} |
| 11 {%- for module_name in args["autoload"] -%} | 38 {%- for module_name in args["autoload"] -%} |
| 12 {%- if module_name in modules -%} | 39 {%- if module_name in modules -%} |
| 13 require({{ module_name|json }}); | 40 require({{ module_name|json }}); |
| 14 {% endif %} | 41 {% endif %} |
| 15 {%- endfor -%} | 42 {%- endfor -%} |
| 16 {%- else -%} | 43 {%- else -%} |
| 17 {%- for module_name, script in modules -%} | 44 {%- for module_name, script in modules -%} |
| 18 {{ script }} | 45 {{ script }} |
| 19 {% endfor -%} | 46 {% endfor -%} |
| 20 {%- endif -%} | 47 {%- endif -%} |
| OLD | NEW |