Skip to content

Releases: bufbuild/protobuf-es

v2.0.0-alpha.1

22 Apr 09:55
91ac90f
Compare
Choose a tag to compare
v2.0.0-alpha.1 Pre-release
Pre-release

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 proto2 required support
  • #738 type-save full enum value names (TBD)

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!

v1.9.0

22 Apr 11:11
ec5af7f
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.8.0...v1.9.0

v1.8.0

14 Mar 16:30
6ca6810
Compare
Choose a tag to compare

What's Changed

  • Introduce type guard isMessage by @timostamm in #728
  • Remove node export conditions by @smaye81 in #744
  • Replace instanceof Message usages by @smaye81 in #729
  • Add /*@__PURE__*/ annotation for better tree-shaking support by @pmzi in #470
  • Introduce type ScalarValue and rename function scalarDefaultValue by @timostamm in #711
  • Add "dependencies" to DescFile by @timostamm in #727
  • Update to google protobuf v26.0 by @timostamm in #747
  • Deprecate field helper functions from @bufbuild/protoplugin by @timostamm in #712
  • Deprecate properties toString and text of JSDocBlock by @timostamm in #721

New Contributors

  • @pmzi made their first contribution in #470

Full Changelog: v1.7.2...v1.8.0

v1.7.2

01 Feb 12:12
31daf8c
Compare
Choose a tag to compare

What's Changed

  • Fix name collision with import in generated code by @timostamm in #688
  • Add missing extension to import of descriptor-set for module resolution NodeNext by @tehwalris in #690
  • Fix proto3 extension presence for singular, non-optional scalar by @timostamm in #689
  • Fix typing for proto2 required fields with target=dts by @timostamm in #691

New Contributors

Full Changelog: v1.7.1...v1.7.2

v1.7.1

29 Jan 17:15
c912f62
Compare
Choose a tag to compare

What's Changed

  • Avoid parsing feature-set defaults at module initialization by @timostamm in #683
  • Fix printing large 64-bit integers in @bufbuild/protoplugin by @timostamm in #682
  • Fix parsing JSON null in proto2 by @timostamm in #685

Full Changelog: v1.7.0...v1.7.1

v1.7.0

24 Jan 17:18
db0bd03
Compare
Choose a tag to compare

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

Full Changelog: v1.6.0...v1.7.0

v1.6.0

12 Dec 18:01
2e01070
Compare
Choose a tag to compare

What's Changed

  • Add CommonJS support as a plugin option by @timostamm in #648
  • Add GeneratedFile.jsDoc() and other features to @bufbuild/protoplugin by @timostamm in #649

Full Changelog: v1.5.1...v1.6.0

v1.5.1

06 Dec 15:45
e700336
Compare
Choose a tag to compare

What's Changed

  • Add explicit exports for Node by @smaye81 in #645
  • Honor experimental editions in the preamble generated by @bufbuild/protoplugin by @timostamm in #644
  • Fix typing error in @bufbuild/protoplugin, improve error messages by @timostamm in #642
  • Support for proto2 groups by @timostamm in #640

Full Changelog: v1.5.0...v1.5.1

v1.5.0

30 Nov 12:29
d0049b3
Compare
Choose a tag to compare

This release includes preliminary support for editions. Please note that it's still an experimental feature.

What's Changed

  • Match typeUrls with leading slash in google.protobuf.Any by @grod220 in #618
  • Expose experimental syntax "editions" in descriptor sets by @timostamm in #621
  • Expose experimental edition features in descriptor sets by @timostamm in #627

New Contributors

Full Changelog: v1.4.2...v1.5.0

v1.4.2

06 Nov 15:51
f597bd1
Compare
Choose a tag to compare

What's Changed

  • Add @bufbuild/protobuf to the direct dependencies of protoc-gen-es by @timostamm in #601
  • Update to google protobuf v25.0 by @timostamm in #608

Full Changelog: v1.4.1...v1.4.2