Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/google-cloud-pubsub-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
],
"scripts": {
"clean": "gts clean",
"compile": "tsc -p . && cp -r protos build/ && minifyProtoJson",
"compile": "tsc -p . && cp -r protos build/",
"compile-protos": "compileProtos src",
"docs": "jsdoc -c .jsdoc.js",
"fix": "gts fix",
"lint": "gts check",
"prepare": "npm run compile-protos && npm run compile",
"postpack": "minifyProtoJson",

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.

high

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.

Suggested change
"postpack": "minifyProtoJson",
"prepack": "minifyProtoJson",
References
  1. 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.

"prepare": "npm run compile",
"system-test": "node ../../bin/run-test.cjs --config ../../.mocharc.cjs --no-parallel build/system-test",
"test": "node ../../bin/run-test.cjs --config ../../.mocharc.cjs build/test"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/google-developer-knowledge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
],
"scripts": {
"clean": "gts clean",
"compile": "tsc -p . && cp -r protos build/ && minifyProtoJson",
"compile": "tsc -p . && cp -r protos build/",
"compile-protos": "compileProtos src",
"docs": "jsdoc -c .jsdoc.js",
"fix": "gts fix",
"lint": "gts check",
"prepare": "npm run compile-protos && npm run compile",
"postpack": "minifyProtoJson",

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.

high

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.

Suggested change
"postpack": "minifyProtoJson",
"prepack": "minifyProtoJson",
References
  1. 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.

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

"prepare": "npm run compile",
"system-test": "node ../../bin/run-test.cjs --config ../../.mocharc.cjs --no-parallel build/system-test",
"test": "node ../../bin/run-test.cjs --config ../../.mocharc.cjs build/test"
},
Expand Down
Loading