diff options
Diffstat (limited to 'src/google')
-rwxr-xr-x | src/google/protobuf/compiler/js/js_generator.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index dd76a509..dfa22ac6 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -3458,7 +3458,8 @@ void Generator::GenerateFile(const GeneratorOptions& options, for (int i = 0; i < file->dependency_count(); i++) { const string& name = file->dependency(i)->name(); printer->Print( - "var $alias$ = require('$file$');\n", + "var $alias$ = require('$file$');\n" + "goog.object.extend(proto, $alias$);\n", "alias", ModuleAlias(name), "file", GetRootPath(file->name(), name) + GetJSFilename(options, name)); @@ -3497,10 +3498,12 @@ void Generator::GenerateFile(const GeneratorOptions& options, GenerateExtension(options, printer, *it); } - if ((options.import_style == GeneratorOptions::kImportCommonJs || - options.import_style == GeneratorOptions::kImportCommonJsStrict)) { + if (options.import_style == GeneratorOptions::kImportCommonJs) { printer->Print("goog.object.extend(exports, $package$);\n", "package", GetFilePath(options, file)); + } else if(options.import_style == GeneratorOptions::kImportCommonJsStrict) { + printer->Print("goog.object.extend(exports, proto);\n", + "package", GetFilePath(options, file)); } // Emit well-known type methods. |