Left: | ||
Right: |
OLD | NEW |
---|---|
1 {%- if args["module"] -%} | 1 {%- if args["module"] -%} |
2 if (typeof require == "undefined") | |
3 { | |
4 window.require = function(module) | |
Sebastian Noack
2017/03/31 14:50:45
This will still assume that there is a global "win
kzar
2017/03/31 15:16:54
Perhaps it matters for Firefox, can't harm to fix
kzar
2017/03/31 15:27:37
(gecko-webext devbuild seems to run OK with these
| |
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 require.modules["info"] = function(module, exports) | |
Sebastian Noack
2017/03/31 14:50:45
The "info" module should only be added for the bac
kzar
2017/03/31 15:16:54
Done.
| |
18 { | |
19 {% if type == "gecko-webext" %} | |
20 {% include "geckoInfo.js.tmpl" %} | |
Sebastian Noack
2017/03/31 14:50:45
Why not just inline them here? Those templates are
kzar
2017/03/31 15:16:54
I prefer them as separate files, I think it's easi
| |
21 {% elif type == "chrome" or type == "edge" %} | |
22 {% include "chromeInfo.js.tmpl" %} | |
23 {% endif %} | |
24 return module.exports; | |
25 }; | |
26 | |
2 {%- for module_name, script in modules -%} | 27 {%- for module_name, script in modules -%} |
3 require.modules[{{ module_name|json }}] = function(module, exports) | 28 require.modules[{{ module_name|json }}] = function(module, exports) |
4 { | 29 { |
5 {{ script }} | 30 {{ script }} |
6 return module.exports; | 31 return module.exports; |
7 }; | 32 }; |
8 | 33 |
9 {% endfor -%} | 34 {% endfor -%} |
10 {%- set modules = dict(modules) -%} | 35 {%- set modules = dict(modules) -%} |
11 {%- for module_name in args["autoload"] -%} | 36 {%- for module_name in args["autoload"] -%} |
12 {%- if module_name in modules -%} | 37 {%- if module_name in modules -%} |
13 require({{ module_name|json }}); | 38 require({{ module_name|json }}); |
14 {% endif %} | 39 {% endif %} |
15 {%- endfor -%} | 40 {%- endfor -%} |
16 {%- else -%} | 41 {%- else -%} |
17 {%- for module_name, script in modules -%} | 42 {%- for module_name, script in modules -%} |
18 {{ script }} | 43 {{ script }} |
19 {% endfor -%} | 44 {% endfor -%} |
20 {%- endif -%} | 45 {%- endif -%} |
OLD | NEW |