Skip to content

Commit

Permalink
fix(temporary): reorder imports to work around protobuf.js problem (#108
Browse files Browse the repository at this point in the history
)

Apparently,  `protobuf.js` is not currently importing the `Any` type when `any.proto` is last in the import list, but the import does work if `any.proto` is higher in the import list. Pending a fix for this in `protobuf.js`, this change imports `any.proto` earlier to avoid triggering the problem. When `protobuf.js` is fixed, we can revert the change to maintain alphabetical ordering of imports.
  • Loading branch information
vchudnov-g authored Dec 6, 2023
1 parent f531645 commit 74c0ede
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public void writeToFile(PrintWriter writer, ProtoFile protoFile, boolean outputC

writer.println("package " + metadata.getProtoPkg() + ";\n");

// TODO: Place this import in the right alphabetical order. We are placing it here for now to
// work around an apparent bug in protobuf.js, where having this particular import be the last
// one makes the file not actually be imported.
if (protoFile.HasAnyFields()) {
writer.println("import \"google/protobuf/any.proto\";");
}

writer.println("import \"google/api/annotations.proto\";");
writer.println("import \"google/api/client.proto\";");
writer.println("import \"google/api/field_behavior.proto\";");
Expand All @@ -53,9 +60,6 @@ public void writeToFile(PrintWriter writer, ProtoFile protoFile, boolean outputC
if (protoFile.isHasLroDefinitions()) {
writer.println("import \"google/cloud/extended_operations.proto\";");
}
if (protoFile.HasAnyFields()) {
writer.println("import \"google/protobuf/any.proto\";");
}
writer.println();

// File Options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ syntax = "proto3";

package google.cloud.compute.v1small;

import "google/protobuf/any.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/extended_operations.proto";
import "google/protobuf/any.proto";

//
// File Options
Expand Down

0 comments on commit 74c0ede

Please sign in to comment.