Tier B: Onboard esbuild-0.28.0 - #2
Conversation
Reviewer's GuideOnboards esbuild 0.28.0 as a Tier B package by adding a factory build script, smoke verification script, and manifest wiring to produce a main npm package and a Trusted Libraries linux-x64 platform package. Flow diagram for esbuild 0.28.0 Tier B build and smoke verificationflowchart TD
Manifest["manifest.json (esbuild 0.28.0)"]
BuildScript["build.entrypoint.sh"]
GitClone["git clone esbuild@v0.28.0"]
BuildBin["make platform-linux-x64"]
PatchMain["Patch npm/esbuild for @calunga/esbuild-linux-x64"]
PackMain["npm pack esbuild-${VERSION}.tgz"]
PackPlatform["npm pack @calunga/esbuild-linux-x64-${VERSION}.tgz"]
OutMain["out/esbuild-0.28.0.tgz"]
OutPlatform["out/@calunga/esbuild-linux-x64-0.28.0.tgz"]
Smoke["verify.smoke.sh"]
CheckTar["Check tarball contents"]
RunBin["esbuild --version"]
Manifest --> BuildScript
BuildScript --> GitClone --> BuildBin --> PatchMain --> PackMain --> OutMain
BuildBin --> PackPlatform --> OutPlatform
Manifest --> Smoke
Smoke --> CheckTar --> RunBin
OutMain --> CheckTar
OutPlatform --> CheckTar
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues, and left some high level feedback:
- When patching
package.jsoninbuild.entrypoint.sh, thejqexpression replacesoptionalDependenciesentirely instead of merging with any existing entries; consider updating it to merge in the TL platform dep so upstream optionalDependencies are preserved. - In
verify.smoke.sh, the jq selection forMAIN_TGZandPLATFORM_TGZis based only on.type, which could become ambiguous if additional outputs of the same type are added; selecting by.id(e.g.,main,linux-x64-binary) would make the script more robust.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When patching `package.json` in `build.entrypoint.sh`, the `jq` expression replaces `optionalDependencies` entirely instead of merging with any existing entries; consider updating it to merge in the TL platform dep so upstream optionalDependencies are preserved.
- In `verify.smoke.sh`, the jq selection for `MAIN_TGZ` and `PLATFORM_TGZ` is based only on `.type`, which could become ambiguous if additional outputs of the same type are added; selecting by `.id` (e.g., `main`, `linux-x64-binary`) would make the script more robust.
## Individual Comments
### Comment 1
<location path="packages/esbuild/0.28.0/build.entrypoint.sh" line_range="42-44" />
<code_context>
+node scripts/esbuild.js "${LINUX_BIN}" --neutral
+
+echo "[build.entrypoint] Patching main package for TL platform optional dep"
+jq --arg name "${TL_PLATFORM}" --arg version "${VERSION}" \
+ '.optionalDependencies = { ($name): $version }' \
+ "${MAIN_PKG}/package.json" > "${MAIN_PKG}/package.json.tmp"
+mv "${MAIN_PKG}/package.json.tmp" "${MAIN_PKG}/package.json"
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Current jq expression overwrites any existing optionalDependencies block.
This assignment replaces any existing `optionalDependencies`, so any upstream entries would be lost if they’re added in future. To keep upstream optional deps and add the TL one, merge instead, e.g.:
`'.optionalDependencies = (.optionalDependencies // {}) + { ($name): $version }'`
```suggestion
jq --arg name "${TL_PLATFORM}" --arg version "${VERSION}" \
'.optionalDependencies = (.optionalDependencies // {}) + { ($name): $version }' \
"${MAIN_PKG}/package.json" > "${MAIN_PKG}/package.json.tmp"
```
</issue_to_address>
### Comment 2
<location path="packages/esbuild/0.28.0/build.entrypoint.sh" line_range="63-72" />
<code_context>
+mkdir -p "${PLATFORM_STAGE}/bin"
+cp "${UPSTREAM_PLATFORM}/README.md" "${PLATFORM_STAGE}/"
+cp "${LINUX_BIN}" "${PLATFORM_STAGE}/bin/esbuild"
+jq -n --arg name "${TL_PLATFORM}" --arg version "${VERSION}" \
+ '{
+ name: $name,
+ version: $version,
+ description: "The Linux 64-bit binary for esbuild (Trusted Libraries build).",
+ license: "MIT",
+ preferUnplugged: true,
+ engines: { node: ">=18" },
+ os: ["linux"],
+ cpu: ["x64"]
+ }' > "${PLATFORM_STAGE}/package.json"
+
</code_context>
<issue_to_address>
**question (bug_risk):** Platform package.json lacks a bin field even though bin/esbuild is present.
Because this package ships `bin/esbuild` but doesn’t declare a `bin` mapping, direct consumers of `@calunga/esbuild-linux-x64` won’t get a `node_modules/.bin` shim and tools that read `bin` entries won’t detect it. If this binary is meant to be invoked directly (not only via the main wrapper’s install logic), please add a `bin` field like `"bin": { "esbuild": "bin/esbuild" }` to the generated package.json.
</issue_to_address>
### Comment 3
<location path="packages/esbuild/0.28.0/verify.smoke.sh" line_range="9-10" />
<code_context>
+: "${PACKAGE_DIR:?PACKAGE_DIR required}"
+
+VERSION="$(jq -r .version "${MANIFEST_PATH}")"
+MAIN_TGZ="$(jq -r '.outputs[] | select(.type == "npm-package") | .path' "${MANIFEST_PATH}")"
+PLATFORM_TGZ="$(jq -r '.outputs[] | select(.type == "tl-platform-package") | .path' "${MANIFEST_PATH}")"
+
+MAIN_PATH="${PACKAGE_DIR}/${MAIN_TGZ}"
</code_context>
<issue_to_address>
**issue:** jq selection will silently pick the last matching output if multiple entries share the same type.
Because the jq expression returns all matching `.path` values, command substitution will only keep the last one. If the manifest ever has multiple `npm-package` or `tl-platform-package` outputs, this will silently validate an arbitrary one. Consider also matching on a stable identifier (e.g. `select(.id == "main")`) or asserting there is exactly one match (e.g. using `halt_error` if `length != 1`).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| jq --arg name "${TL_PLATFORM}" --arg version "${VERSION}" \ | ||
| '.optionalDependencies = { ($name): $version }' \ | ||
| "${MAIN_PKG}/package.json" > "${MAIN_PKG}/package.json.tmp" |
There was a problem hiding this comment.
suggestion (bug_risk): Current jq expression overwrites any existing optionalDependencies block.
This assignment replaces any existing optionalDependencies, so any upstream entries would be lost if they’re added in future. To keep upstream optional deps and add the TL one, merge instead, e.g.:
'.optionalDependencies = (.optionalDependencies // {}) + { ($name): $version }'
| jq --arg name "${TL_PLATFORM}" --arg version "${VERSION}" \ | |
| '.optionalDependencies = { ($name): $version }' \ | |
| "${MAIN_PKG}/package.json" > "${MAIN_PKG}/package.json.tmp" | |
| jq --arg name "${TL_PLATFORM}" --arg version "${VERSION}" \ | |
| '.optionalDependencies = (.optionalDependencies // {}) + { ($name): $version }' \ | |
| "${MAIN_PKG}/package.json" > "${MAIN_PKG}/package.json.tmp" |
| jq -n --arg name "${TL_PLATFORM}" --arg version "${VERSION}" \ | ||
| '{ | ||
| name: $name, | ||
| version: $version, | ||
| description: "The Linux 64-bit binary for esbuild (Trusted Libraries build).", | ||
| license: "MIT", | ||
| preferUnplugged: true, | ||
| engines: { node: ">=18" }, | ||
| os: ["linux"], | ||
| cpu: ["x64"] |
There was a problem hiding this comment.
question (bug_risk): Platform package.json lacks a bin field even though bin/esbuild is present.
Because this package ships bin/esbuild but doesn’t declare a bin mapping, direct consumers of @calunga/esbuild-linux-x64 won’t get a node_modules/.bin shim and tools that read bin entries won’t detect it. If this binary is meant to be invoked directly (not only via the main wrapper’s install logic), please add a bin field like "bin": { "esbuild": "bin/esbuild" } to the generated package.json.
| MAIN_TGZ="$(jq -r '.outputs[] | select(.type == "npm-package") | .path' "${MANIFEST_PATH}")" | ||
| PLATFORM_TGZ="$(jq -r '.outputs[] | select(.type == "tl-platform-package") | .path' "${MANIFEST_PATH}")" |
There was a problem hiding this comment.
issue: jq selection will silently pick the last matching output if multiple entries share the same type.
Because the jq expression returns all matching .path values, command substitution will only keep the last one. If the manifest ever has multiple npm-package or tl-platform-package outputs, this will silently validate an arbitrary one. Consider also matching on a stable identifier (e.g. select(.id == "main")) or asserting there is exactly one match (e.g. using halt_error if length != 1).
e04c12f to
43de349
Compare
43de349 to
85458cd
Compare
Signed-off-by: David Peraza <dperaza@redhat.com>
85458cd to
f0b7fb2
Compare
First package onboard test
Summary by Sourcery
Onboard esbuild 0.28.0 as a Tier B package with a Trusted Libraries linux-x64 binary and JS wrapper, including build and smoke verification scripts.
New Features:
Build:
Tests: