Skip to content

Add plugin option elide_plugin_version=true#1336

Merged
timostamm merged 2 commits intomainfrom
tstamm/Add-plugin-option-`elide_plugin_version=true`
Jan 12, 2026
Merged

Add plugin option elide_plugin_version=true#1336
timostamm merged 2 commits intomainfrom
tstamm/Add-plugin-option-`elide_plugin_version=true`

Conversation

@timostamm
Copy link
Copy Markdown
Member

This PR adds a new plugin option to @bufbuild/protoc-gen-es (and all plugins based on @bufbuild/protoplugin):

elide_plugin_version=true

By default, protoc-gen-es inserts its version number at the top of each generated file. To remove the version number, set elide_plugin_version=true. Be aware that we recommend to keep plugin and runtime versions in sync, and that this option can make it more difficult to spot a mismatch.

Closes #1294

@AdrienVannson
Copy link
Copy Markdown

The PR is nice, but is it the right thing to do?

I think this information is useful, and I would expect users to either not commit generated files or ignore the diff (for example, on github, with linguist-generated=true in .gitattributes as we do in our own implementations). Updating the plugin is likely to update the generated files anyway, right?

@jtszalay
Copy link
Copy Markdown

jtszalay commented Jan 9, 2026

Updating the plugin is likely to update the generated files anyway, right?

We don't find that to be true most of the time. These diffs as show in the image cause us to have ~300+ linguist-generated=true and bog down reviews in github.

Screenshot 2026-01-09 at 11 16 02

@sbarfurth
Copy link
Copy Markdown

not commit generated files

We use Bazel for building and not updating files for which content doesn't change will ensure build actions don't need to run again. So even without checking things in this would save build time.

@timostamm timostamm merged commit 9c8a643 into main Jan 12, 2026
23 checks passed
@timostamm timostamm deleted the tstamm/Add-plugin-option-`elide_plugin_version=true` branch January 12, 2026 09:46
@timostamm
Copy link
Copy Markdown
Member Author

is it the right thing to do?

Ideally, we'd generate code that's perfect for every use case - unfortunately, that's impossible because of mutually exclusive requirements. The next best solution would be to provide options to modify the generated code for every use case - unfortunately, that makes the project unmaintainable. That's why we need to be judicious regarding new plugin options (as explained in the FAQ).

But the goal for protobuf-es is still to be as useful and convenient as possible. This plugin option isn't without drawbacks, but I believe that it fits the bill.

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.

feature request: add option to strip protoc-gen-es version from code gen preamble

4 participants