Skip to content

Use map_imports in the example - #185

Merged
timostamm merged 6 commits into
mainfrom
tstamm/Use-rewrite_imports-in-the-example
Sep 11, 2026
Merged

Use map_imports in the example#185
timostamm merged 6 commits 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 map_imports of @bufbuild/protoc-gen-es to map 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!

@timostamm

Copy link
Copy Markdown
Member Author

We're going to switch to the new map_imports once released, see bufbuild/protobuf-es#1528

@timostamm
timostamm merged commit bc11ab6 into main Sep 11, 2026
14 checks passed
@timostamm
timostamm deleted the tstamm/Use-rewrite_imports-in-the-example branch September 11, 2026 11:34
@anuraaga anuraaga changed the title Use rewrite_imports in the example Use map_imports in the example Sep 11, 2026
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