Skip to content

Conversation

@pcj
Copy link
Contributor

@pcj pcj commented Dec 17, 2025

Replaces the Node.js-based generate-version-header.js script with a C++ implementation to eliminate the Node.js runtime dependency from the build process. The new C++ tool reads package.json and generates the same version.h header file.

Also fixes Closure Compiler errors under strict mode in extension_field_binary_info.js and map.js by properly assigning goog.requireType calls to const variables instead of using standalone goog.requireType calls.

Changes:

  • Add generator/generate-version-header.cc with C++ implementation
  • Remove generate-version-header.js
  • Update generator/BUILD.bazel to use cc_binary instead of Node.js script
  • Add rules_cc dependency to MODULE.bazel
  • Update BUILD.bazel to remove deleted script from exports_files
  • Fix goog.requireType usage in extension_field_binary_info.js and map.js

Context: prefactor for getting protobuf-javascript in the bazel central registry. The goal is for a module consumer to be able to build the generator and consume the .js files. In the current state, the generate-version-header.js script assumes the client has node installed non-hermetically. To properly support this would require an additional / unnecessary dependency. As such, replaced it with a C++ version, which works fine and removes the build dependency.

Will followup with another PR to add BCR boilerplate. Thanks!

Replaces the Node.js-based generate-version-header.js script with a C++
implementation to eliminate the Node.js runtime dependency from the build
process. The new C++ tool reads package.json and generates the same
version.h header file.

Also fixes Closure Compiler errors under strict mode in
extension_field_binary_info.js and map.js by properly assigning
goog.requireType calls to const variables instead of using standalone
goog.requireType calls.

Changes:
- Add generator/generate-version-header.cc with C++ implementation
- Remove generate-version-header.js
- Update generator/BUILD.bazel to use cc_binary instead of Node.js script
- Add rules_cc dependency to MODULE.bazel
- Update BUILD.bazel to remove deleted script from exports_files
- Fix goog.requireType usage in extension_field_binary_info.js and map.js
@pcj
Copy link
Contributor Author

pcj commented Dec 17, 2025

Other changes are related to (1) buildifier (good) and (2) js formatting changes (maybe annoying). LMK if I should revert that part.

@dibenede dibenede merged commit a908831 into protocolbuffers:main Dec 18, 2025
4 checks passed
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