Skip to content

fix(ph-cli): define the fs arg types on cmd-ts's root entry - #3155

Merged
acaldas merged 1 commit into
mainfrom
fix/cmd-ts-bun-batteries-fs
Oct 1, 2026
Merged

acaldas merged 1 commit into
mainfrom
fix/cmd-ts-bun-batteries-fs

Conversation

@acaldas

@acaldas acaldas commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Under bun 1.4.2, ph-cli's postbuild (bun run scripts/generate-commands-docs.ts) intermittently fails (run):

TypeError: require() async module ".../chalk@5.6.2/.../chalk/source/index.js" is unsupported. use "await import()" instead.
  at .../cmd-ts/dist/cjs/subcommands.js:40
  ...
  at .../cmd-ts/dist/cjs/batteries/fs.js:9

This is the bun regression worked around in #3133 (oven-sh/bun#33180, fix oven-sh/bun#37185 unmerged). That patch routes cmd-ts to its ESM build under bun, but six generate-* commands import cmd-ts/dist/cjs/batteries/fs.js directly, which pulls the CJS index.js and its require("chalk") back in.

clis/ph-cli/src/utils/fs-args.ts defines Directory and File (same behaviour as cmd-ts's batteries/fs) on the root cmd-ts entry, and the six commands import them from there. ph-cli now imports only "cmd-ts", which resolves under both the workspace patch and the stock package that published installs get. The patch is unchanged.

  • Under bun 1.4.2, generate-commands-docs.ts loads 27 CJS cmd-ts modules on main and 0 on this branch.
  • The bun failure is racy and didn't reproduce locally (macOS or oven/bun:1.4.2), so this removes the path from the stack trace rather than turning a local repro green.
  • Checked: ph-cli build (with bun 1.4.2) and tests 195/195, typecheck and lint clean, COMMANDS.md unchanged; the Node-built CLI rejects a missing path ("Path doesn't exist") and a directory passed as a file ("Provided path is not a file").

Copilot AI balanced review requested due to automatic review settings October 1, 2026 14:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The conditional export and all affected imports are consistent, with no stale deep imports or patch hashes remaining.

Review effort: Balanced
Findings: None

What changed in this PR

Routes cmd-ts filesystem helpers through a Bun-aware export, avoiding the CJS/chalk failure while preserving Node behavior.

Changes:

  • Adds a conditional ./batteries/fs export to the cmd-ts patch.
  • Updates six generate commands to use the public subpath.
  • Refreshes the patched dependency hash.
File Description
pnpm-lock.yaml Updates the cmd-ts patch hash.
patches/​cmd-ts@0.15.0.patch Adds Bun/CJS filesystem-helper exports.
clis/​ph-cli/​src/​commands/​generate-subgraph.ts Uses the exported filesystem helpers.
clis/​ph-cli/​src/​commands/​generate-processor.ts Uses the exported filesystem helpers.
clis/​ph-cli/​src/​commands/​generate-piece.ts Uses the exported filesystem helpers.
clis/​ph-cli/​src/​commands/​generate-editor.ts Uses the exported filesystem helpers.
clis/​ph-cli/​src/​commands/​generate-document-model.ts Uses the exported filesystem helpers.
clis/​ph-cli/​src/​commands/​generate-app.ts Uses the exported filesystem helpers.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@acaldas
acaldas force-pushed the fix/cmd-ts-bun-batteries-fs branch from 5f0f927 to f861a1b Compare October 1, 2026 15:00
@acaldas acaldas changed the title fix(ph-cli): load cmd-ts's fs batteries through the bun export condition fix(ph-cli): define the fs arg types on cmd-ts's root entry Oct 1, 2026
@acaldas
acaldas merged commit 3efe464 into main Oct 1, 2026
18 checks passed
@acaldas
acaldas deleted the fix/cmd-ts-bun-batteries-fs branch October 1, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants