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

Powered by Google App Engine
This is Rietveld