protobuf-es icon indicating copy to clipboard operation
protobuf-es copied to clipboard

Bazel rule

Open doronrosenberg opened this issue 3 years ago • 6 comments

A Bazel rule for protobuf-es would be very enticing for me as I've found the bazel/typescript/grpc world to be frustrating and trying to get non-rules_proto_grpc rules to work with Bazel was painful (and eventually gave up). I see that rules_proto_grpc already has some buf rules for linting/etc.

doronrosenberg avatar Aug 04 '22 21:08 doronrosenberg

Hey Doron, apologies for the late reply.

We do have a rules_buf repository, but it does not include code generation. From what I've heard from our team, Bazel is quite peculiar about the inputs/outputs and much more restrictive than the proto plugin contract, making a general bazel rule for plugins practically impossible.

That means we would need a rule specific to protobuf-es, and at this point in time, this is out of scope for this project. I am happy to leave this issue open though, and if people express interest, we might be able to provide such a rule.

timostamm avatar Aug 16 '22 08:08 timostamm

We have added a plugin option to keep empty files in https://github.com/bufbuild/protobuf-es/pull/229, making it easier to integrate with Bazel:

keep_empty_files=true

By default, protoc-gen-es (and all other plugins based on @bufbuild/protoplugin) omit empty files from the plugin output. This option disables pruning of empty files, to allow for smooth interoperation with Bazel and similar tooling that requires all output files to be declared ahead of time.

timostamm avatar Nov 02 '22 16:11 timostamm

Hi, good news, my company is working on this now.

alexeagle avatar Aug 16 '23 01:08 alexeagle

Hi @alexeagle, I'm interested in generating TypeScript files using buf in bazel. Any documentation or code examples you can point me to for doing this?

refactornator avatar Jun 11 '24 21:06 refactornator

@refactornator that's exactly what ts_proto_library does: https://github.com/aspect-build/rules_ts/blob/main/docs/proto.md

alexeagle avatar Jun 11 '24 22:06 alexeagle

Excellent, I'll try that out. Thanks @alexeagle!

refactornator avatar Jun 12 '24 17:06 refactornator