npm / pbf
pbf
What changed in pbf 4 to 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-27.
6 breaking2 security5 new APIs and options4 performance2 tooling5 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initpbf 517 changes
Breaking changes 2
The Pbf class is split into PbfReader and PbfWriter classes, allowing bundlers to tree-shake the half you don't use.
The legacy readVarint64 method is removed; use readVarint(true) for signed 64-bit reads.
Security 1
Fixes a minor compiler vulnerability that could allow code injection via an unsafe schema.
New APIs and options 5
The pbf CLI can generate TypeScript declarations for compiled code and write them to a .d.ts file.
Type names qualified with a package, such as google.protobuf.Any, are now supported.
The CLI accepts include directories to resolve imports, with -I as an alias for --proto_path.
A new entry point loads .proto files together with their imports for use with compile.
Added PbfReader.nextField(end) for more compact, readable, and bulletproof decoding while preserving performance.
Performance 4
Decoding is ~17% faster and encoding is ~7% faster on the vector tile benchmark.
A fast path improves performance by 20% on the vector tiles encoding benchmark.
A single-byte fast path improves performance for the common case, including tags and small integers.
Uses typedArray.set instead of a manual copy loop.
Tooling 1
TypeScript types are now available for pbf/compile.
Fixes and other changes 4
Fixes encoding of certain supplementary characters, such as CJK Extension B.
Fixes string encoding dropping a trailing lone surrogate after another lone lead.
Now honors a non-zero byteOffset of the backing buffer.
Fixes a bug in compiled packed sfixed64 fields.
pbf 47 changes
Breaking changes 4
Code generation produces ESM modules by default; use --legacy for CommonJS.
The library is exposed as an ES module, and CommonJS support is dropped.
Generated code uses flat exports of read and write functions instead of nested objects, producing simpler, more compact code that is more susceptible to efficient minimization.
The codebase uses modern ES syntax; developers can transpile it to retain IE11 support.
Security 1
Field names are sanitized to protect against injection via malicious proto schemas.
Tooling 1
The library adds first-class typings via JSDoc comments and a TypeScript type check.
Fixes and other changes 1
Writing default oneof fields is fixed.