Skip to content

Use rewrite_imports in the example - #185

Open
timostamm wants to merge 1 commit into
mainfrom
tstamm/Use-rewrite_imports-in-the-example
Open

Use rewrite_imports in the example#185
timostamm wants to merge 1 commit into
mainfrom
tstamm/Use-rewrite_imports-in-the-example

Conversation

@timostamm

@timostamm timostamm commented Sep 3, 2026

Copy link
Copy Markdown
Member

The package @bufbuild/protovalidate uses code generated for buf/build/validate.proto internally.
The private package packages/protovalidate-bench generates a second copy.
With #151, @bufbuild/protovalidate exports its generated code.

This PR uses the option rewrite_imports of @bufbuild/protoc-gen-es to rewrite the import for buf/build/validate.proto, to point to @bufbuild/protovalidate/gen/buf/build/validate_pb.js, so that only a single copy exists.

Using the option requires @bufbuild/protobuf v2.14.1 or later.

This reduces the raw bundle size of the example by ~9%, and nearly 7% after brotli compression.

@sudorandom sudorandom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see an example of this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants