diff options
author | Josh Haberman <jhaberman@gmail.com> | 2016-02-04 10:29:27 -0800 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2016-02-18 10:30:21 -0800 |
commit | e9f31ee3d7cf7c0f370607e54dbea01ba7240a77 (patch) | |
tree | 67eb860493c5e1c3d9aaa51386f484dd3eefe493 /src/google | |
parent | 55cc3aa987159bcdb491550d864115c1e8daeebb (diff) | |
download | protobuf-e9f31ee3d7cf7c0f370607e54dbea01ba7240a77.tar.gz protobuf-e9f31ee3d7cf7c0f370607e54dbea01ba7240a77.tar.bz2 protobuf-e9f31ee3d7cf7c0f370607e54dbea01ba7240a77.zip |
CommonJS tests are now passing.
Diffstat (limited to 'src/google')
-rwxr-xr-x | src/google/protobuf/compiler/js/js_generator.cc | 6 |
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); } |