npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

protobuf-es-v1-v2-codemod

v0.1.3

Published

Codemod to migrate protobuf-es v1 to v2

Downloads

393

Readme

protobuf-es-v1-v2-codemod

A jscodeshift-based codemod tool to automate migration from protobuf-es v1 to v2. Also supports connect-es v2 migration.

Motivation

protobuf-es v2 introduced a major shift from a class-based API to a plain object + schema-based functional API. This requires numerous changes across existing codebases:

  • new User({...})create(UserSchema, {...})
  • User.fromBinary(bytes)fromBinary(UserSchema, bytes)
  • msg.toBinary()toBinary(UserSchema, msg)
  • PlainMessage<User>User
  • Well-Known Type import path changes
  • connect-es import path and type name changes
  • ...and more

This codemod automates these mechanical transformations, significantly reducing the effort required for manual migration.

Usage

Run all transforms at once (recommended):

npx protobuf-es-v1-v2-codemod --transform=all src/

Run a specific transform:

npx protobuf-es-v1-v2-codemod --transform=message-constructor src/

Options

| Option | Description | |--------|-------------| | --transform=<name\|all> | Transform to run. Use all to run all transforms in the recommended order | | --dry | Dry run. Preview changes without modifying files | | --print | Print transformed output to stdout |

Transforms

connect-es v2 migration

| Transform | Description | Before | After | |-----------|-------------|--------|-------| | connect-import-path | Rewrite _connect import paths to _pb | import { ... } from "./gen/example_connect" | import { ... } from "./gen/example_pb" | | connect-client-types | Rename client types and functions | PromiseClient / createPromiseClient | Client / createClient |

protobuf-es v2 migration

| Transform | Description | Before | After | |-----------|-------------|--------|-------| | message-constructor | Convert constructors to create() | new User({name: "Homer"}) | create(UserSchema, {name: "Homer"}) | | static-methods | Convert static methods to standalone functions | User.fromBinary(bytes) | fromBinary(UserSchema, bytes) | | instance-methods | Convert instance methods to standalone functions | msg.toBinary() | toBinary(UserSchema, msg) | | to-plain-message | Remove toPlainMessage() calls | msg.toPlainMessage() | msg | | plain-message | Convert PlainMessage<T> / PartialMessage<T> types | PlainMessage<User> | User | | well-known-type-imports | Move WKT imports to @bufbuild/protobuf/wkt | import { Timestamp } from "@bufbuild/protobuf" | import { TimestampSchema } from "@bufbuild/protobuf/wkt" | | wkt-static-methods | Convert WKT static methods to standalone functions | Timestamp.fromDate(date) | timestampFromDate(date) | | instanceof-message | Convert instanceof checks to isMessage() | x instanceof User | isMessage(x, UserSchema) | | protobuf-value-ref | Convert message type value references to Schema | Type used as a value | Corresponding Schema descriptor | | proto3-enum | Convert proto3.getEnumType() to Schema-based API | proto3.getEnumType(MyEnum).findNumber(n) | MyEnumSchema.values.find(v => v.number === n) | | extension-option-ref | Convert extension Schema references to GenExtension | Legacy proto extension API | GenExtension object | | protoplugin-v2 | Migrate protoplugin imports and API to v2 | @bufbuild/protoplugin/ecmascript | @bufbuild/protoplugin |

Execution order

When using --transform=all, transforms are automatically executed in the order listed above. This recommended order accounts for dependencies between transforms (e.g., instance-methods can leverage results from message-constructor and static-methods).

Limitations

  • The instance-methods transform infers variable types statically. If the type cannot be inferred from type annotations, constructors, or static methods, the call is skipped (conservative by design).
  • Generated code (*_pb files) is not transformed. Re-generate with protoc-gen-es v2 instead.
  • Supported file extensions: .ts, .tsx, .js, .jsx
  • node_modules/, dist/, and .next/ are automatically excluded.

License

MIT