diff options
author | Peter Marton <pmarton@netflix.com> | 2018-03-26 16:07:45 -0700 |
---|---|---|
committer | Peter Marton <pmarton@netflix.com> | 2018-05-08 09:23:56 -0700 |
commit | 13f94b4092cff9bc36a62adb4bf2e362b4f85979 (patch) | |
tree | e78104e42e6d56aa0233a829371bf639bfd3e469 /src/google/protobuf/compiler | |
parent | 3c4e36847330df7c6b3e136b5abf590466dac164 (diff) |
Fix strict JS generator with import in a protofile
Diffstat (limited to 'src/google/protobuf/compiler')
-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. |