Repository navigation
fix: remove compile-protos from prepare script in pubsub-api and developer-knowledge - #9666
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the build scripts in package.json for both google-cloud-pubsub-api and google-developer-knowledge packages, moving the minifyProtoJson execution to the postpack lifecycle hook and simplifying the prepare script. However, executing minification during postpack occurs after the npm package tarball is created, which would result in publishing unminified files. It is recommended to use the prepack hook instead to ensure minified files are included in the package, and to add these files to the keep list (e.g., librarian.yaml) to prevent them from being overwritten during regeneration.
| "fix": "gts fix", | ||
| "lint": "gts check", | ||
| "prepare": "npm run compile-protos && npm run compile", | ||
| "postpack": "minifyProtoJson", |
There was a problem hiding this comment.
Running minifyProtoJson in postpack occurs after the npm package tarball has already been created. This means the published package will contain the unminified proto JSON files, defeating the purpose of minification. It should be run in prepack instead so that the minified files are included in the packed tarball. Note that since this is an auto-generated package.json, you should add this file to the keep list (e.g., in librarian.yaml) to prevent it from being overwritten during regeneration.
| "postpack": "minifyProtoJson", | |
| "prepack": "minifyProtoJson", |
References
- Manual edits to auto-generated files (such as package.json in client libraries) are acceptable if the file is added to the keep list (e.g., in librarian.yaml) to prevent it from being overwritten during regeneration.
| "fix": "gts fix", | ||
| "lint": "gts check", | ||
| "prepare": "npm run compile-protos && npm run compile", | ||
| "postpack": "minifyProtoJson", |
There was a problem hiding this comment.
Running minifyProtoJson in postpack occurs after the npm package tarball has already been created. This means the published package will contain the unminified proto JSON files, defeating the purpose of minification. It should be run in prepack instead so that the minified files are included in the packed tarball. Note that since this is an auto-generated package.json, you should add this file to the keep list (e.g., in librarian.yaml) to prevent it from being overwritten during regeneration.
| "postpack": "minifyProtoJson", | |
| "prepack": "minifyProtoJson", |
References
- Manual edits to auto-generated files (such as package.json in client libraries) are acceptable if the file is added to the keep list (e.g., in librarian.yaml) to prevent it from being overwritten during regeneration.
| "fix": "gts fix", | ||
| "lint": "gts check", | ||
| "prepare": "npm run compile-protos && npm run compile", | ||
| "postpack": "minifyProtoJson", |
There was a problem hiding this comment.
Nit: do we even need to run this anymore? I believe librarian should be generating proto files already so there shouldn't be a need to re-generate them.
There was a problem hiding this comment.
Keeping "postpack": "minifyProtoJson" here to match the other ~225 generated packages in packages/ and core/packages/. We can evaluate removing or changing postpack across the monorepo templates separately.
Fixes release failures for
@google-cloud/pubsub-apiand@google/developer-knowledgeby aligning theirprepare,compile, andpostpackscripts with the rest of the monorepo packages.Key Changes:
"prepare"from"npm run compile-protos && npm run compile"to"npm run compile"."compile"from"tsc -p . && cp -r protos build/ && minifyProtoJson"to"tsc -p . && cp -r protos build/"."postpack": "minifyProtoJson".