Skip to content

feat(tools): add --no-comments support to compileProtos to reduce proto file size#8890

Merged
feywind merged 2 commits into
googleapis:mainfrom
quirogas:feat/gapic-tools-no-comments
Jul 16, 2026
Merged

feat(tools): add --no-comments support to compileProtos to reduce proto file size#8890
feywind merged 2 commits into
googleapis:mainfrom
quirogas:feat/gapic-tools-no-comments

Conversation

@quirogas

Copy link
Copy Markdown
Contributor

Adds support for --no-comments in compileProtos to reduce the file size of proto.js files.

When --no-comments is passed, compileProtos first runs pbjs with comments so that pbts can construct the complete TypeScript type definitions in protos.d.ts. Afterward, comments and whitespace in protos.js (and protos.cjs) are stripped using uglify-js.

This addresses file size limits on large proto packages (e.g., google-cloud-compute exceeding GitHub's 100MB file limit). Stripping comments reduces protos.js file size by ~82% while keeping TypeScript types and runtime interfaces fully backwards compatible

For #8889
For googleapis/librarian#6638

@quirogas quirogas self-assigned this Jul 16, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a '--no-comments' flag to the 'compileProtos' tool, allowing users to strip comments from generated JavaScript files using 'uglify-js'. The review feedback highlights that the current implementation lacks error handling for the minification process and suggests refactoring the duplicated 'uglify-js' options. Additionally, the reviewer requested a new test case to verify the functionality of the '--no-comments' flag.

Comment thread core/packages/tools/src/compileProtos.ts
Comment thread core/packages/tools/test/compileProtos.ts
@quirogas
quirogas marked this pull request as ready for review July 16, 2026 19:47
@quirogas
quirogas requested a review from a team as a code owner July 16, 2026 19:47
@feywind
feywind merged commit 685b428 into googleapis:main Jul 16, 2026
34 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