aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/README.md4
-rw-r--r--js/binary/utils_test.js2
-rw-r--r--js/commonjs/export.js6
-rw-r--r--js/commonjs/export_asserts.js4
-rw-r--r--js/commonjs/rewrite_tests_for_commonjs.js8
5 files changed, 18 insertions, 6 deletions
diff --git a/js/README.md b/js/README.md
index 4b1ec8a1..9d63559f 100644
--- a/js/README.md
+++ b/js/README.md
@@ -22,7 +22,9 @@ To use Protocol Buffers with JavaScript, you need two main components:
`npm install google-protobuf`, or use the files in this directory.
2. The Protocol Compiler `protoc`. This translates `.proto` files
into `.js` files. The compiler is not currently available via
- npm -- you must download and compile it from GitHub or a tarball.
+ npm, but you can download a pre-built binary
+ [on GitHub](https://github.com/google/protobuf/releases)
+ (look for the `protoc-*.zip` files under **Downloads**).
Setup
diff --git a/js/binary/utils_test.js b/js/binary/utils_test.js
index 37bab080..1b90855d 100644
--- a/js/binary/utils_test.js
+++ b/js/binary/utils_test.js
@@ -39,7 +39,7 @@
goog.require('goog.crypt.base64');
goog.require('goog.testing.asserts');
-// CommonJS-LoadFromFile: google_protobuf
+// CommonJS-LoadFromFile: googleProtobuf
goog.require('jspb.BinaryConstants');
goog.require('jspb.BinaryWriter');
goog.require('jspb.utils');
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 {