From 7726cd207c66f2595f647e79c5c2c499eed7f8db Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Tue, 16 Feb 2016 15:29:49 -0800 Subject: Integrate review comments. --- js/commonjs/export.js | 6 ++++++ js/commonjs/export_asserts.js | 4 ++++ js/commonjs/rewrite_tests_for_commonjs.js | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'js/commonjs') diff --git a/js/commonjs/export.js b/js/commonjs/export.js index 2fc2fcbd..a3cfbd6f 100644 --- a/js/commonjs/export.js +++ b/js/commonjs/export.js @@ -5,6 +5,12 @@ * the google-protobuf.js file that we build at distribution time. */ +goog.require('goog.object'); +goog.require('jspb.BinaryReader'); +goog.require('jspb.BinaryWriter'); +goog.require('jspb.ExtensionFieldInfo'); +goog.require('jspb.Message'); + exports.Message = jspb.Message; exports.BinaryReader = jspb.BinaryReader; exports.BinaryWriter = jspb.BinaryWriter; diff --git a/js/commonjs/export_asserts.js b/js/commonjs/export_asserts.js index 9b823d3c..5219d120 100644 --- a/js/commonjs/export_asserts.js +++ b/js/commonjs/export_asserts.js @@ -30,4 +30,8 @@ for (var key in global) { } } +// The COMPILED variable is set by Closure compiler to "true" when it compiles +// JavaScript, so in practice this is equivalent to "exports.COMPILED = true". +// This will disable some debugging functionality in debug.js. We could +// investigate whether this can/should be enabled in CommonJS builds. exports.COMPILED = COMPILED diff --git a/js/commonjs/rewrite_tests_for_commonjs.js b/js/commonjs/rewrite_tests_for_commonjs.js index 6a655c1e..2ab7b2c1 100644 --- a/js/commonjs/rewrite_tests_for_commonjs.js +++ b/js/commonjs/rewrite_tests_for_commonjs.js @@ -46,21 +46,21 @@ lineReader.on('line', function(line) { if (module) { // Skip goog.require() lines before the first directive. var full_sym = is_require[1]; var sym = tryStripPrefix(full_sym, pkg); - console.log("google_protobuf.exportSymbol('" + full_sym + "', " + module + sym + ', global);'); + console.log("googleProtobuf.exportSymbol('" + full_sym + "', " + module + sym + ', global);'); } } else if (is_loadfromfile) { if (!module) { - console.log("var google_protobuf = require('google-protobuf');"); + console.log("var googleProtobuf = require('google-protobuf');"); console.log("var asserts = require('closure_asserts_commonjs');"); console.log("var global = Function('return this')();"); console.log(""); console.log("// Bring asserts into the global namespace."); - console.log("google_protobuf.object.extend(global, asserts);"); + console.log("googleProtobuf.object.extend(global, asserts);"); } module = is_loadfromfile[1].replace("-", "_"); pkg = is_loadfromfile[2]; - if (module != "google_protobuf") { // We unconditionally require this in the header. + if (module != "googleProtobuf") { // We unconditionally require this in the header. console.log("var " + module + " = require('" + is_loadfromfile[1] + "');"); } } else { -- cgit v1.2.3