Releases: bufbuild/protobuf-es
v2.1.0
What's Changed
- Fix assignability of wrong message type in create by @timostamm in #972
- Generate full JSDoc for JSON types by @timostamm in #975
Full Changelog: v2.0.0...v2.1.0
v2.0.0
What's new in version 2
To support Protobuf editions, we have to make breaking changes that also affect users of proto2 and proto3. This prompted us to make more extensive changes that take feedback from version 1 into account:
We no longer use classes. Instead, we generate a schema object and a type for every message. To create a new instance, to serialize, and for other concerns, we provide functions. Here is a simple example:
import { create, toBinary } from "@bufbuild/protobuf";
import { UserSchema } from "./gen/example_pb";
let user = create(UserSchema, {
firstName: "Homer",
lastName: "Simpson",
active: true,
});
const bytes = toBinary(UserSchema, user);
If you use proto3, messages are now plain objects. Files with proto2 and editions use the prototype chain to track field presence.
This approach solves several outstanding issues, such as:
- #397 Provide custom options at runtime
- #551 Generated types allow assigning wrong message type if it is a superset of the target type
- #414 Improvements for proto2 required
- #738 type-save full enum value names
- #928 Better interop with 3rd party frameworks requiring plain objects
- #508 JSON types
Tip
Take a look at the upgrade guide to learn more.
Note
Connect-ES does not support version 2 yet. We will update it shortly.
Contributors
Thanks to @srikrsna-buf for his contributions to v2!
v2.0.0-beta.3
What's Changed
This is the third beta release for version 2. See v2.0.0-alpha.1 for an introduction. To install beta packages, run npm install @bufbuild/protobuf@beta @bufbuild/protoc-gen-es@beta
.
- Add GeneratedFile.array by @timostamm in #935
- Add DescEnum.value by @timostamm in #927
- Rename GenDescMessage to GenMessage by @timostamm in #925
- Improve plugin option import_extension by @timostamm in #909
- Add $typeName first by @timostamm in #923
- Fix createFileRegistry() with empty arguments by @timostamm in #933
Full Changelog: v2.0.0-beta.2...v2.0.0-beta.3
v2.0.0-beta.2
What's Changed
This is the second beta release for version 2. See v2.0.0-alpha.1 for an introduction. To install beta packages, run npm install @bufbuild/protobuf@beta @bufbuild/protoc-gen-es@beta
.
- Avoid Array.flatMap by @timostamm in #904
Full Changelog: v2.0.0-beta.1...v2.0.0-beta.2
v2.0.0-beta.1
What's Changed
This is the first beta release for version 2. See v2.0.0-alpha.1 for an introduction. To install beta packages, run npm install @bufbuild/protobuf@beta @bufbuild/protoc-gen-es@beta
.
- Bump
typescript
version in protoplugin by @srikrsna-buf in #879 - Improve parameter parsing by @srikrsna-buf in #880
- Throw errors in ReflectMessage instead of returning them by @timostamm in #882
- Add typeOnly argument to GeneratedFile.import by @timostamm in #887
- Fix create() with wrapper oneof field by @timostamm in #889
- Improve clash resolution in generated names by @timostamm in #888
- Use suffix "Schema" for generated descriptors by @timostamm in #890
- Use JsonObject to represent google.protobuf.Struct by @timostamm in #893
- JSON Types by @timostamm in #866
- Add mutable registry by @timostamm in #898
- Avoid the prototype chain with editions if possible by @timostamm in #897
Full Changelog: v2.0.0-alpha.4...v2.0.0-beta.1
v2.0.0-alpha.4
What's Changed
This is the fourth alpha release for version 2. See v2.0.0-alpha.1 for an introduction.
- Remove addListItem and setMapEntry from ReflectMessage by @timostamm in #875
- Relax validation in BinaryWriter by @timostamm in #877
Full Changelog: v2.0.0-alpha.3...v2.0.0-alpha.4
v2.0.0-alpha.3
What's Changed
This is the third alpha release for version 2. See v2.0.0-alpha.1 for an introduction.
- Move Registry to the top level exports by @timostamm in #841
- Rename
exportDecl
toexport
by @srikrsna-buf in #843 - Fix Registry exports by @timostamm in #846
- Fix JSON error message by @timostamm in #849
- Replace LongType with a boolean by @timostamm in #851
- Update generated service types to use generated desc types by @srikrsna-buf in #856
- Remove
ecmascript
subpath by @srikrsna-buf in #857 - Rename JSON serialization option emitDefaultValues by @timostamm in #863
- Change return type of merge functions by @timostamm in #867
- Add
method
field toDescMethod
; Improve generated service types by @srikrsna-buf in #874
Full Changelog: v2.0.0-alpha.2...v2.0.0-alpha.3
v1.10.0
What's Changed
- Skip null values in message initializer object by @timostamm in #862
- Fix Node10 subpath fallbacks by @timostamm in #803
- Check for matching field numbers in StartGroup / EndGroup tags by @smaye81 in #816
- Update to google protobuf v27.0 by @timostamm in #854
Full Changelog: v1.9.0...v1.10.0
v2.0.0-alpha.2
What's Changed
This is the second alpha release for version 2. See v2.0.0-alpha.1 for an introduction.
Breaking
- Change default value of plugin option
import_extension
tonone
by @srikrsna-buf in #832 - Bump supported version of TypeScript to 4.9.5 by @timostamm in #805
- Remove Node10 subpath fallbacks by @timostamm in #804
- Remove DescField.optional by @timostamm in #808
- Mark all exports from codegenv1 private by @timostamm in #806
Fixes
- Strip only last .proto suffix for DescFile.name by @timostamm in #807
- Fix wrapper extension JSON serialization by @timostamm in #821
- Check for matching field numbers in StartGroup / EndGroup tags by @timostamm in #810
- For deprecated elements, generate a
@deprecated
tag on descriptors by @timostamm in #818
New Features
- Add option accessors by @timostamm in #828
- Support option retention by @timostamm in #827
- Introduce DescMessage.field by @timostamm in #839
- Add function parentTypes() to reflect by @timostamm in #817
- Make DescField.presence available for all fields by @timostamm in #822
- Generate comments for feature options by @timostamm in #809
- Return zero values from ReflectMessage.get by @timostamm in #813
- Rely on ReflectMessage for jstype=JS_STRING by @timostamm in #823
Performance improvements
- Add localName property to DescField and others by @timostamm in #834
- Avoid JIT deoptimizations by @timostamm in #836
- Speed up reflect with classes by @timostamm in #837
Full Changelog: v2.0.0-alpha.1...v2.0.0-alpha.2
v2.0.0-alpha.1
What's new in version 2
To support Protobuf editions, we have to make breaking changes that also affect users of proto2 and proto3. This prompted us to make more extensive changes that take feedback from version 1 into account:
We no longer uses classes. Instead, we generate a type and a descriptor for every message, and provide functions to create a new instance, for serialization, and other concerns. Here is a simple example:
import { create, toBinary, fromBinary, fromJsonString } from "@bufbuild/protobuf";
import { UserDesc } from "./gen/user_pb.js";
let user = create(UserDesc, {
firstName: "Homer",
lastName: "Simpson",
active: true,
locations: ["Springfield"],
projects: { SPP: "Springfield Power Plant" },
manager: {
firstName: "Montgomery",
lastName: "Burns",
},
});
const bytes = toBinary(UserDesc, user);
user = fromBinary(UserDesc, bytes);
user = fromJsonString(UserDesc, '{"firstName": "Homer", "lastName": "Simpson"}');
This approach solves several outstanding issues, such as:
- #397 Provide custom options at runtime
- #551 Generated types allow assigning wrong message type if it is a superset of the target type
- #414 Improvements for proto2 required
- #738 type-save full enum value names
- #928 Better interop with 3rd party frameworks requiring plain objects
- #508 JSON types
If you use proto3, messages are now plain objects. Files with proto2 and editions use the prototype chain to track field presence.
Please note that this is an alpha release, and APIs might still change. We're also missing documentation yet. But if you want to try it out, we welcome your feedback!
This release is published with the alpha
tag. To install the alpha packages, you can run:
npm install @bufbuild/protobuf@alpha @bufbuild/protoc-gen-es@alpha
Contributors
Thanks to @srikrsna-buf for his contributions to v2!