Skip to content

fix(agent): use tsup watcher for dev mode instead of tsx (fixes #253)#310

Merged
rz1989s merged 1 commit into
mainfrom
fix/agent-dev-mode-tsup
Jun 5, 2026
Merged

fix(agent): use tsup watcher for dev mode instead of tsx (fixes #253)#310
rz1989s merged 1 commit into
mainfrom
fix/agent-dev-mode-tsup

Conversation

@rz1989s
Copy link
Copy Markdown
Member

@rz1989s rz1989s commented Jun 5, 2026

Summary

Resolves #253. The agent's dev script (tsx watch src/index.ts) has crashed at boot since Phase D because @bonfida/spl-name-service@3.0.21 ships a borsh ESM bundle that tsx's ESM loader cannot instantiate (plain Node handles it fine).

Fix

Switch dev to a tsup watcher matching the root pattern:

  • devtsup --watch src --onSuccess 'node dist/index.js'
  • new packages/agent/tsup.config.ts (esm, node22, skipNodeModulesBundle: true)
  • add tsup to devDependencies

tsup transpiles only the agent's own source and runs the output with plain node, sidestepping tsx's loader. skipNodeModulesBundle: true is required — without it, tsup bundles the transitive CJS chain (bs58safe-bufferrequire("buffer")) into one ESM file and fails with Dynamic require of "buffer" is not supported.

Verification

pnpm exec tsup builds clean (368 KB); node dist/index.js boots past all imports to the normal env validation (FATAL: SIPHER_NETWORK env var required) — confirming both the original borsh SyntaxError and the dynamic-require error are gone.

Production build (tsc) + start are unchanged — this only touches dev mode. tsx is retained in devDependencies (may be used for ad-hoc scripts).

Fixes #253. `tsx watch src/index.ts` has crashed at boot since Phase D:
@bonfida/spl-name-service@3.0.21 ships a borsh ESM bundle that tsx's ESM
loader cannot instantiate (plain Node handles it fine).

Switch the agent dev script to `tsup --watch src --onSuccess 'node
dist/index.js'`, matching the root pattern. tsup transpiles only the
agent's own source and runs the output with plain node, sidestepping
tsx's loader.

skipNodeModulesBundle is required: bundling the transitive CJS chain
(bs58 -> safe-buffer -> require("buffer")) into one ESM file otherwise
fails with "Dynamic require of buffer is not supported".

Verified: the agent boots past all imports to the normal SIPHER_NETWORK
env check -- no borsh SyntaxError, no dynamic-require error. Production
build (tsc) + start are unchanged.
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sipher Ready Ready Preview, Comment Jun 5, 2026 10:39pm

@rz1989s rz1989s merged commit 7187e55 into main Jun 5, 2026
8 checks passed
@rz1989s rz1989s deleted the fix/agent-dev-mode-tsup branch June 5, 2026 22:56
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.

Agent dev mode (tsx) broken since Phase D — switch to tsup --watch

1 participant