feat!: Replace protobuf.js
This PR replaces protobuf.js with @bufbuild/protobuf in generated code. The libraries are used for low-level wire encoding. Since they have a similar API, the changes to main.ts are relatively simple.
The main advantage is that Long.js is no longer a dependency, unless you explicitly want to use Long.js (plugin option forceLong=long).
The signatures of encode and decode change - they no longer use Reader and Writer from protobuf.js, but the counterparts from @bufbuild/protobuf. This will be a breaking change for users that manually pass in readers, or rely on the returned writer to be a specific type.
Follow-ups:
- ~Replace
Readerin src/schema.ts~ https://github.com/stephenh/ts-proto/pull/1058/commits/0d763e98ad96abded801a45d1b53370564f9950d - ~Re-generate code for
ts-proto-descriptors~ https://github.com/stephenh/ts-proto/pull/1058/commits/3ae88891b08d21597f085bdaabbf1404e9e44c9e - ~Move
protobufjsfrom dependencies to devDependencies~ https://github.com/stephenh/ts-proto/pull/1058/commits/7ef0c73543706c069a9e189ac02511316495afda
@stephenh, I took care of the follow-ups.
This is using an alpha of @bufbuild/protobuf v2. I promise we won't break it if you want to publish as is. A stable v2 is about a month out in case you prefer to wait.
ts-proto-descriptors should be published first - the ts-proto package.json has a dep on it.
Amazing, thank you @timostamm !
A beta of @bufbuild/protobuf is available, and it won't be long until it's stable. I'll update this PR once the stable v2 is published.
Awesome! Thanks for the update @timostamm !
@timostamm @stephenh It looks like @bufbuild/protobuf v2 stable has been released. Any chance we can now get this PR merged/released?
This is amazing, as usual, @timostamm , thank you for the bump to the latest!
I merged this to main, with a semantic-release change to hopefully push it out as an alpha release, and we can see if that works! :crossed_fingers:
Just wanted to say thanks again @timostamm ! Really appreciate the help on this PR, and looking forward to @bufbuild/protobuf being a much better runtime for us! :pray:
Sorry, I was out for a couple of days. This was fun 😃 Congratulations on the v2 release!