Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Unified Diff: mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl

Issue 2759563004: Mojo JS bindings: change module loading solution. (Closed)
Patch Set: Make sure mojo_bindings.js is packaged in build result for running layout tests. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
diff --git a/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl b/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
index 1616e7c9d7820eeefa4eddfe88698ca8e6116113..7eadbe338c5f59e2ee6eef8851a7a36809ea5e16 100644
--- a/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
+++ b/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
@@ -2,19 +2,38 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+{%- if use_new_js_bindings %}
+
+"use strict";
+
+(function() {
+ // TODO(yzshen): Define these aliases to minimize the differences between the
+ // old/new modes. Remove them when the old mode goes away.
+ var bindings = mojo;
+ var codec = mojo.internal;
+ var validator = mojo.internal;
+{%- for import in imports %}
+ var {{import.unique_name}} = {{import.module.namespace}};
+{%- endfor %}
+
+{% include "module_definition.tmpl" %}
+})();
+
+{%- else %}
+
define("{{module.path}}", [
{%- if module.path !=
"mojo/public/interfaces/bindings/interface_control_messages.mojom" and
module.path !=
"mojo/public/interfaces/bindings/pipe_control_messages.mojom" %}
"mojo/public/js/bindings",
-{%- endif %}
+{%- endif %}
"mojo/public/js/codec",
"mojo/public/js/core",
"mojo/public/js/validator",
-{%- for import in imports %}
+{%- for import in imports %}
"{{import.module.path}}",
-{%- endfor %}
+{%- endfor %}
], function(
{%- if module.path !=
"mojo/public/interfaces/bindings/interface_control_messages.mojom" and
@@ -22,12 +41,14 @@ define("{{module.path}}", [
"mojo/public/interfaces/bindings/pipe_control_messages.mojom" -%}
bindings, {% endif -%}
codec, core, validator
-{%- for import in imports -%}
+{%- for import in imports -%}
, {{import.unique_name}}
-{%- endfor -%}
+{%- endfor -%}
) {
{%- include "module_definition.tmpl" %}
return exports;
});
+
+{%- endif %}
« no previous file with comments | « mojo/public/js/new_bindings/validator.js ('k') | mojo/public/tools/bindings/generators/js_templates/module_definition.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698