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

protobuf-ts relationship to connect-web

Open pquerna opened this issue 3 years ago • 2 comments

Hello!

Thank you again for this wonderful library.

With the recent announcement of connect-web: https://buf.build/blog/connect-web-protobuf-grpc-in-the-browser https://github.com/bufbuild/connect-web

I was wondering what the plans are for this library? Should we consider connect-web to be the defacto replacement / v3 of protobuf-ts?

pquerna avatar Aug 04 '22 17:08 pquerna

See https://github.com/timostamm/protobuf-ts/discussions/324

jcready avatar Aug 04 '22 17:08 jcready

connect-web is not a replacement of protobuf-ts, but parts of protobuf-es will be.

connect-web is actually two projects:

  1. connect-web, a code generator for gRPC-web and the Connect protocol
  2. protobuf-es, a code generator for messages and enums

I believe this separation of concerns is actually important to improve protobuf for JS. I've been using protobuf in Go a bit lately, and they have a pretty nice package that makes it really easy to write your own plugins: https://pkg.go.dev/google.golang.org/protobuf/compiler/protogen I believe we need something similar in JS, so that we can move away from monolithic projects like ts-proto and protobuf-ts. If the project cannot generate what you need, you are out of luck. Instead, users should be able to write their own code generators easily.

If you look at the source code of connect-web, that seems to work pretty well. It is really just around 1,600 lines of library code, plus a code generator, and it can evolve independently of protobuf-es.

This change wasn't feasible iteratively. So unfortunately, we are stuck with two code generators that share very similar types. Ultimately, I hope that protobuf-ts becomes a code generator (or suite of code generators?) that uses the base types provided by protobuf-es. Obviously this will require some work to allow a smooth transition - for example, see the points raised by James in the discussion. But in result, it will massively reduce the complexity of protobuf-ts.

timostamm avatar Aug 05 '22 00:08 timostamm