grpc-web icon indicating copy to clipboard operation
grpc-web copied to clipboard

Remove Unused bindings for Annotations Imports?

Open gtalarico opened this issue 6 years ago • 8 comments

My .proto file includes imports that are never used by the generated JS client - eg. import google/api/annotations.proto import "protoc-gen-swagger/options/annotations.proto"

I was able to generate the JS client with protoc-get-grpc-web, however, the generated code includes those imports even though they are not used by the client:

var google_api_annotations_pb = require('../../google/api/annotations_pb.js')
var protoc$gen$swagger_options_annotations_pb = require('../../protoc-gen-swagger/options/annotations_pb.js')
// Lint Errors:
>>> var `google_api_annotations_pb` is declared but its value is never read
>>> var `google_protobuf_empty_pb` is declared but its value is never read

Is there something in place to prevent unused bindings from being included in the generated code?

Similar issue with grpc-gateway code gen: https://github.com/grpc-ecosystem/grpc-gateway/issues/310

gtalarico avatar Apr 10 '19 15:04 gtalarico

Any updates on this? I'm new to grpc-web, my backend is in go, and I don't know what to do about this. (e.g. ../../google/api/annotations_pb.js isn't even a file path that would be within my repo.

Did you work around this somehow @gtalarico ?

josdotso avatar Feb 14 '20 13:02 josdotso

Any updates on this? I'm new to grpc-web, my backend is in go, and I don't know what to do about this. (e.g. ../../google/api/annotations_pb.js isn't even a file path that would be within my repo.

Did you work around this somehow @gtalarico ?

I ended up with lines like this in my Makefile:

ls -1 api/pb/*.js | xargs sed -i '/google_api_annotations_pb =/d'

josdotso avatar Feb 18 '20 20:02 josdotso

Are there any updates on this?

RicCu avatar Nov 01 '20 04:11 RicCu

would love to see some progress on this one, since it's a really annoying issue

fr33kvanderwand avatar Mar 22 '21 14:03 fr33kvanderwand

the same issue

ghost avatar Mar 28 '21 17:03 ghost

Is this project alive or dead?

mmykola1234567890 avatar Jun 08 '21 13:06 mmykola1234567890

Same issue here. I started with annotating in a side-car yaml and then decided to move the annotations inline in the proto file. But came to find that it is actually a bit annoying for every client to need to satisfy those extra annotation dependencies (python, C++, ..) in the generated code when they dont need them. Its the same problem for grpc-gateway / openapi/swagger

justinfx avatar Sep 27 '21 05:09 justinfx

I think my recent PR #1235 should resolve this problem; could some of you try my PR and report if it solves the problem. If not I would like to get a minimal reproducer.

meling avatar Apr 30 '22 18:04 meling