Releases: bufbuild/protobuf-es
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!
v1.9.0
What's Changed
- Expose OneofInfo type by @q42jaap in #746
- Fix typo in error output by @stefanvanburen in #755
- Build ESM artifacts with Node16 moduleResolution by @smaye81 in #754
- Support unknown fields in clone by @srikrsna-buf in #758
- Fix assertion for FIXED32 scalar type when parsing JSON by @timostamm in #771
- Avoid reserved object property names in generated enumerations by @timostamm in #777
- Generate type imports when possible for .d.ts by @timostamm in #778
- Update to Protobuf v26.1 by @smaye81 in #797
New Contributors
- @q42jaap made their first contribution in #746
- @stefanvanburen made their first contribution in #755
Full Changelog: v1.8.0...v1.9.0
v1.8.0
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
Full Changelog: v1.7.2...v1.8.0
v1.7.2
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
- @tehwalris made their first contribution in #690
Full Changelog: v1.7.1...v1.7.2
v1.7.1
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
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
v1.6.0
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