aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/js/js_generator.cc
diff options
context:
space:
mode:
authorGravatar Josh Haberman <jhaberman@gmail.com>2016-02-04 10:29:27 -0800
committerGravatar Josh Haberman <jhaberman@gmail.com>2016-02-18 10:30:21 -0800
commite9f31ee3d7cf7c0f370607e54dbea01ba7240a77 (patch)
tree67eb860493c5e1c3d9aaa51386f484dd3eefe493 /src/google/protobuf/compiler/js/js_generator.cc
parent55cc3aa987159bcdb491550d864115c1e8daeebb (diff)
CommonJS tests are now passing.
Diffstat (limited to 'src/google/protobuf/compiler/js/js_generator.cc')
-rwxr-xr-xsrc/google/protobuf/compiler/js/js_generator.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc
index 31938b11..2dea60fa 100755
--- a/src/google/protobuf/compiler/js/js_generator.cc
+++ b/src/google/protobuf/compiler/js/js_generator.cc
@@ -2516,6 +2516,10 @@ void Generator::GenerateFile(const GeneratorOptions& options,
// Generate "require" statements.
if (options.import_style == GeneratorOptions::IMPORT_COMMONJS) {
+ printer->Print("var jspb = require('google-protobuf');\n");
+ printer->Print("var goog = jspb;\n");
+ printer->Print("var global = Function('return this')();\n\n");
+
for (int i = 0; i < file->dependency_count(); i++) {
const std::string& name = file->dependency(i)->name();
printer->Print(
@@ -2537,7 +2541,7 @@ void Generator::GenerateFile(const GeneratorOptions& options,
//FindProvidesForFields(options, printer, extensions, &provided);
for (std::set<string>::iterator it = provided.begin();
it != provided.end(); ++it) {
- printer->Print("goog.exportSymbol('$name$', null, this);\n",
+ printer->Print("goog.exportSymbol('$name$', null, global);\n",
"name", *it);
}