Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: templates/modules.js.tmpl

Issue 29399569: Issue 5060 - Move require into modules template, make info a module (Closed)
Left Patch Set: Created March 31, 2017, 5:44 a.m.
Right Patch Set: Improve check for require Created April 1, 2017, 1:27 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « templates/geckoInfo.js.tmpl ('k') | tests/test_packagerEdge.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 {%- if args["module"] -%} 1 {%- if args["module"] -%}
2 function require(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 { 3 {
4 if (!(module in require.scopes)) 4 var require = function(module)
5 { 5 {
6 let scope = {exports: {}}; 6 if (!(module in require.scopes))
7 require.scopes[module] = require.modules[module](scope, scope.exports); 7 {
8 } 8 let scope = {exports: {}};
9 return require.scopes[module]; 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);
10 } 15 }
11 require.modules = Object.create(null); 16
12 require.scopes = Object.create(null); 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 %}
13 28
14 {%- for module_name, script in modules -%} 29 {%- for module_name, script in modules -%}
15 require.modules[{{ module_name|json }}] = function(module, exports) 30 require.modules[{{ module_name|json }}] = function(module, exports)
16 { 31 {
17 {{ script }} 32 {{ script }}
18 return module.exports; 33 return module.exports;
19 }; 34 };
20 35
21 {% endfor -%} 36 {% endfor -%}
22 {%- set modules = dict(modules) -%} 37 {%- set modules = dict(modules) -%}
23 {%- for module_name in args["autoload"] -%} 38 {%- for module_name in args["autoload"] -%}
24 {%- if module_name in modules -%} 39 {%- if module_name in modules -%}
25 require({{ module_name|json }}); 40 require({{ module_name|json }});
26 {% endif %} 41 {% endif %}
27 {%- endfor -%} 42 {%- endfor -%}
28 {%- else -%} 43 {%- else -%}
29 {%- for module_name, script in modules -%} 44 {%- for module_name, script in modules -%}
30 {{ script }} 45 {{ script }}
31 {% endfor -%} 46 {% endfor -%}
32 {%- endif -%} 47 {%- endif -%}
LEFTRIGHT

Powered by Google App Engine
This is Rietveld