What's Changed
This release adds support for extensions, a Protobuf language feature that allows to extend a message with an additional field.
For example:
syntax = "proto2";
message User {
extensions 100 to 200;
}
extend User {
optional uint32 age = 100;
}For the extension age, we generate a new export const age: Extension<User, number>. You can set the extension field with the function setExtension:
import { setExtension } from "@bufbuild/protobuf";
import { User, age } from "./example_pb.js";
const user = new User();
setExtension(user, age, 77);To learn more about the details, see the API documentation.
For plugin authors: Since extensions provide a better way to access custom options in a plugin, we are deprecating the findCustom*Option functions from @bufbuild/protoplugin/ecmascript. We recommend to switch to extensions for better type safety and flexibility, see the PR for details.
All changes
- Support extensions by @timostamm in #666
- Deprecate findCustom*Option functions in favor of extensions by @timostamm in #669
- Document extensions by @timostamm in #672
- Support experimental editions in @bufbuild/protoplugin by @timostamm in #655
- Improve errors for unsupported editions in createDescriptorSet by @timostamm in #654
Full Changelog: v1.6.0...v1.7.0