unstale

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 init

@unstale/cli on npm

pbf 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.

    5.0.0release notes

  • The legacy readVarint64 method is removed; use readVarint(true) for signed 64-bit reads.

    5.0.0release notes

Security 1

  • Fixes a minor compiler vulnerability that could allow code injection via an unsafe schema.

    5.1.2release notes

New APIs and options 5

  • The pbf CLI can generate TypeScript declarations for compiled code and write them to a .d.ts file.

    5.2.0release notes

  • Type names qualified with a package, such as google.protobuf.Any, are now supported.

    5.2.0release notes

  • The CLI accepts include directories to resolve imports, with -I as an alias for --proto_path.

    5.2.0release notes

  • A new entry point loads .proto files together with their imports for use with compile.

    5.2.0release notes

  • Added PbfReader.nextField(end) for more compact, readable, and bulletproof decoding while preserving performance.

    5.1.0release notes

Performance 4

  • Decoding is ~17% faster and encoding is ~7% faster on the vector tile benchmark.

    5.2.0release notes

  • A fast path improves performance by 20% on the vector tiles encoding benchmark.

    5.1.1release notes

  • A single-byte fast path improves performance for the common case, including tags and small integers.

    5.0.0release notes

  • Uses typedArray.set instead of a manual copy loop.

    5.0.0release notes

Tooling 1

  • TypeScript types are now available for pbf/compile.

    5.2.0release notes

Fixes and other changes 4

  • Fixes encoding of certain supplementary characters, such as CJK Extension B.

    5.1.3release notes

  • Fixes string encoding dropping a trailing lone surrogate after another lone lead.

    5.1.3release notes

  • Now honors a non-zero byteOffset of the backing buffer.

    5.1.1release notes

  • Fixes a bug in compiled packed sfixed64 fields.

    5.0.0release notes

pbf 47 changes

Breaking changes 4

  • Code generation produces ESM modules by default; use --legacy for CommonJS.

    4.0.0release notes

  • The library is exposed as an ES module, and CommonJS support is dropped.

    4.0.0release notes

  • 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.

    4.0.0release notes

  • The codebase uses modern ES syntax; developers can transpile it to retain IE11 support.

    4.0.0release notes

Security 1

  • Field names are sanitized to protect against injection via malicious proto schemas.

    4.0.2release notes

Tooling 1

  • The library adds first-class typings via JSDoc comments and a TypeScript type check.

    4.0.0release notes

Fixes and other changes 1