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

Side by Side Diff: templates/modules.js.tmpl

Issue 29399569: Issue 5060 - Move require into modules template, make info a module (Closed)
Patch Set: Created March 31, 2017, 5:44 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « templates/geckoInfo.js.tmpl ('k') | tests/test_packagerEdge.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 -%}
OLDNEW
« no previous file with comments | « templates/geckoInfo.js.tmpl ('k') | tests/test_packagerEdge.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld