Skip to content

Fix flow_run ESM require error, bump to 1.2.2#37

Merged
pallaoro merged 1 commit into
mainfrom
release-v1.2.2
May 20, 2026
Merged

Fix flow_run ESM require error, bump to 1.2.2#37
pallaoro merged 1 commit into
mainfrom
release-v1.2.2

Conversation

@pallaoro
Copy link
Copy Markdown
Member

Summary

flow_run, flow_read, and flow_publish were failing with "require is not defined" whenever a tool call passed a file: parameter — inline flows (no file:) worked, which masked the bug.

Root cause: src/plugin/index.ts had lazy require("path") / require("fs") calls inside resolveFlowFile, versionsDir, listVersions, and readVersion (introduced when flow_list/flow_read/flow_publish landed). The package is published as "type": "module" and tsc with NodeNext emits require() verbatim into the ESM output, so the calls blow up at runtime in the plugin loader.

Fix: replace the inline CJS requires with top-level import * as fs from "node:fs" / import * as path from "node:path" so the helpers work under ESM.

Test plan

  • npm run build — clean, no require() in dist/plugin/index.js
  • node -e "import('./dist/plugin/index.js')" loads cleanly as ESM
  • CI green (npm test on Linux)
  • Post-merge: cut v1.2.2 release → publish.yml ships to npm → re-pull on a VPS and confirm flow_run with file: succeeds

src/plugin/index.ts used inline require("path") / require("fs") inside
the file-path helpers (resolveFlowFile, versionsDir, listVersions,
readVersion), introduced when flow_list/flow_read/flow_publish landed.
The package is published as "type": "module" and tsc with NodeNext
emits the require() calls verbatim into ESM output, so any tool path
that hits a file: arg fails at runtime with "require is not defined".
Inline flows (no file:) sidestep resolveFlowFile and worked, masking
the bug.

Replace the lazy CJS requires with top-level "node:fs" / "node:path"
imports so the helpers work under ESM.
@pallaoro pallaoro merged commit 423dc7d into main May 20, 2026
1 check passed
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.

1 participant