OLD | NEW |
1 {%- if args["module"] -%} | 1 {%- if args["module"] -%} |
| 2 function require(module) |
| 3 { |
| 4 if (!(module in require.scopes)) |
| 5 { |
| 6 let scope = {exports: {}}; |
| 7 require.scopes[module] = require.modules[module](scope, scope.exports); |
| 8 } |
| 9 return require.scopes[module]; |
| 10 } |
| 11 require.modules = Object.create(null); |
| 12 require.scopes = Object.create(null); |
| 13 |
2 {%- for module_name, script in modules -%} | 14 {%- for module_name, script in modules -%} |
3 require.modules[{{ module_name|json }}] = function(module, exports) | 15 require.modules[{{ module_name|json }}] = function(module, exports) |
4 { | 16 { |
5 {{ script }} | 17 {{ script }} |
6 return module.exports; | 18 return module.exports; |
7 }; | 19 }; |
8 | 20 |
9 {% endfor -%} | 21 {% endfor -%} |
10 {%- set modules = dict(modules) -%} | 22 {%- set modules = dict(modules) -%} |
11 {%- for module_name in args["autoload"] -%} | 23 {%- for module_name in args["autoload"] -%} |
12 {%- if module_name in modules -%} | 24 {%- if module_name in modules -%} |
13 require({{ module_name|json }}); | 25 require({{ module_name|json }}); |
14 {% endif %} | 26 {% endif %} |
15 {%- endfor -%} | 27 {%- endfor -%} |
16 {%- else -%} | 28 {%- else -%} |
17 {%- for module_name, script in modules -%} | 29 {%- for module_name, script in modules -%} |
18 {{ script }} | 30 {{ script }} |
19 {% endfor -%} | 31 {% endfor -%} |
20 {%- endif -%} | 32 {%- endif -%} |
OLD | NEW |