fix: resolve cli package.json without import.meta.resolve - #428
ianwremmel-ai-agent wants to merge 3 commits into
Conversation
Plan
Parked as human-blocked on 2026-09-09: both remaining items need a person, and no reply has come in two days. Verification
Review findings triagedTwo passes on Codex (spec-aware and spec-blind), a distinct model family from the authoring one. Both independently returned the same single finding and no functional defects. Acted on:
Carried over from the earlier pass:
Dismissed:
AnnotationsAll 18 dismissed as pre-existing and untouched by this diff, with rationale recorded per annotation: |
|
View your CI Pipeline Execution ↗ for commit 3862cd8
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #428 +/- ##
=======================================
Coverage 80.41% 80.41%
=======================================
Files 23 23
Lines 730 730
Branches 182 182
=======================================
Hits 587 587
Misses 140 140
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tool-tool's src/tool.mjs is compiled to CommonJS as well as ESM. esbuild
turns `import.meta` into an empty object under cjs, so
`import.meta.resolve('@code-like-a-carpenter/cli')` became
`import_meta.resolve(...)` in dist/cjs/tool.cjs — a TypeError for anything
that reaches addAsCliPlugin through the built CJS executor. executors.json
points at the cjs build whenever codegen:tool ran with src/index.mjs absent
(create-nodes.mjs sets buildBeforeRun from that check), which is the state
tool-foundation/executors.json is committed in.
Resolve `@code-like-a-carpenter/cli/package.json` through
createRequire(rootPkgPath) instead. That works in both output formats and
keeps the property the old comment called out: it does not depend on the
CLI entrypoint having been built, because package.json is itself the
resolution target and always exists. Resolving the subpath directly also
drops the findUp walk back up from the entrypoint.
Set esbuild's logOverride so `empty-import-meta` is an error, making a
format-incompatible construct fail @clc/nx:esbuild instead of scrolling
past as a warning. tool.mjs was the only first-party source that tripped
it; @clc/nx itself is exempt because create-nodes gives it no build target.
The comment said the package-json executor emits "./package.json" for every package. Examples take configExample, which does not build an exports map, and @clc/nx never registers the target at all. The precondition that matters is that the CLI itself exports it, so state only that.
1130f12 to
3862cd8
Compare
CI blocker:
|
|
Answering my own question above: the first option was taken. The This PR waits for #437 to land, then rebases onto Annotation triage, all dismissed with rationale recorded:
|
Resume pass: re-verified, still blocked on a humanNothing has moved since 2026-09-08. Head is still Re-verified the deliverable this pass with a fresh build (
The branch is 8 commits behind What is blocking
Both need a person: land #437, then approve this one. Parking it here rather than polling again — three requests over two days have gone unanswered, so another wait cycle adds nothing. |
tool-tool's
src/tool.mjsis compiled to CommonJS as well as ESM. esbuild turnsimport.metainto an empty object under cjs, soimport.meta.resolve("@code-like-a-carpenter/cli")becameimport_meta.resolve(...)indist/cjs/tool.cjs— aTypeErrorfor anything reachingaddAsCliPluginthrough the built CJS executor.executors.jsonpoints at the cjs build whenevercodegen:toolran withsrc/index.mjsabsent (create-nodes.mjsderivesbuildBeforeRunfrom that check), which is the statetool-foundation/executors.jsonis committed in.esbuild flagged this the whole time as an
[empty-import-meta]warning, which does not fail the build and so kept scrolling past.Two changes:
@code-like-a-carpenter/cli/package.jsonthroughcreateRequire(rootPkgPath). Works in both output formats, and keeps the property the old comment insisted on: it does not need the CLI entrypoint to have been built, becausepackage.jsonis itself the resolution target and always exists. Resolving the subpath directly also drops thefindUpwalk back up from the entrypoint.logOverridesoempty-import-metais an error, so a format-incompatible construct cannot land again.tool.mjswas the only first-party source that tripped it.Ticket: https://linear.app/code-like-a-carpenter/issue/CLC-1133/fix-tool-tools-commonjs-build-which-compiles-importmetaresolve-away