Repository navigation
fix: remove compile-protos from prepare - #9690
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the build and packaging scripts across multiple package.json files by removing the compile-protos step from the prepare script and moving the minifyProtoJson task from the compile script to a postpack lifecycle script. Feedback from the reviewer correctly highlights a critical issue: because postpack runs after the tarball has already been generated, any files minified during this step will not be included in the published npm packages. To ensure the minified proto JSON files are packaged correctly, the prepack lifecycle script should be used instead of postpack.
| "fix": "gts fix", | ||
| "lint": "gts check", | ||
| "prepare": "npm run compile-protos && npm run compile", | ||
| "postpack": "minifyProtoJson", |
There was a problem hiding this comment.
In npm, the postpack lifecycle script runs after the tarball has already been generated and packed. Any file modifications performed in postpack (such as running minifyProtoJson to minify the proto JSON files in the build directory) will not be included in the packed tarball that gets published to npm.
To ensure that the published packages actually contain the minified proto JSON files (thereby keeping the package size small), you should use the prepack lifecycle script instead of postpack.
| "postpack": "minifyProtoJson", | |
| "prepack": "minifyProtoJson", |
| "fix": "gts fix", | ||
| "lint": "gts check", | ||
| "prepare": "npm run compile-protos && npm run compile", | ||
| "prepare": "npm run compile", |
There was a problem hiding this comment.
While reviewing the scripts here, note that the adjacent postpack script (on line 62) also runs minifyProtoJson after the tarball has already been packed. This means the minified files are not included in the published package.
Please consider changing postpack to prepack here as well to ensure the minified files are correctly included in the published ESM packages.
Fixes release failures for by aligning their
prepare,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".