News for hackers. Stuff that matters.
Re:Connect-Web: TypeScript library for calling RPC servers f... by hmillison on Thursday August 04, 2022 @01:51PM (#32346055)
I have used protobufs and grpc on the web before. Maybe this project is the magic bullet that makes it easy to do, but in the past that typescript support from Google and 3rd parties (improbable eng) was lacking and there was little interest in making simple changes to make it easier to use.

On top of that, the increase in JS shipped to user's due to the size of the generated protobuf objects was unacceptable for anything that cares about keeping their bundle size manageable. Have you done anything to address this issue?

Re:Connect-Web: TypeScript library for calling RPC servers f... by timostamm on Thursday August 04, 2022 @05:09PM (#32348315)
Not sure if it is a magic bullet, but it was definitely written by TypeScript developers, for TypeScript developers.

The generated TypeScript code is already pretty minimal because all serialization ops are implemented with reflection instead of generated code (which is only marginally slower than generated code in JS).

But you can also switch to generating JavaScript + TypeScript declaration files, which is truly minimal: JavaScript is an entire dynamic language, so we actually only generated a small snippet of metadata in the .js output, and create a class at run time with a function call. The generated typings (.d.ts) give you type safety, autocompletion in the IDE, and so on.

You can see the output here: https://github.com/bufbuild/protobuf-es/blob/main/packages/p...

Re:Connect-Web: TypeScript library for calling RPC servers f... by rockemsockem on Thursday August 04, 2022 @02:49PM (#32346808)
The article specifically mentions that bundle sizes for grpc packages in the past were unacceptable and that they've made big improvements.
Re:Connect-Web: TypeScript library for calling RPC servers f... by mf192 on Thursday August 04, 2022 @02:55PM (#32346875)
Ye, fwiw there is an example code size comparison here:

https://github.com/bufbuild/connect-web/blob/main/packages/c...

I'm sure someone will chime in on the implementation details, but hopefully others can give it a try with their projects!

Re:Connect-Web: TypeScript library for calling RPC servers f... by hmillison on Thursday August 04, 2022 @04:54PM (#32348188)
That's great news! I missed that in my initial skim of the article.