[codex] fix node workflow dynamic require builds#3
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f47c30cc46
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| const NODE_REQUIRE_BANNER = [ | ||
| `import { createRequire as __voyantCreateRequire } from "node:module";`, | ||
| `const require = __voyantCreateRequire(import.meta.url);`, |
There was a problem hiding this comment.
Avoid declaring a fixed top-level require
For --platform node this banner is prepended verbatim to every bundled ESM file, so any workflow entry that already declares a top-level require (for example the standard Node ESM pattern const require = createRequire(import.meta.url)) will produce a bundle with two top-level require declarations and fail to import during manifest extraction with an identifier redeclaration error. Because esbuild does not parse banner text for name collision avoidance, use an injected/renamed shim or a less collision-prone helper instead of reserving require globally in the bundle.
Useful? React with 👍 / 👎.
Summary
Fixes #2.
This updates node-platform workflow builds so bundled CommonJS dependencies that dynamically require Node built-ins, such as
stream, can be loaded during manifest extraction and by the self-hosted Node runner.Root Cause
The CLI builds workflow entries as ESM and immediately imports
bundle.mjsto collect registered workflows. When esbuild preserves a CommonJS dynamic require helper in a node-platform ESM bundle, Node does not provide an ambientrequire, so manifest extraction fails even though the dependency is valid for Node.Changes
requirewithcreateRequire(import.meta.url).stream.@voyantjs/cli.Validation
pnpm --filter @voyantjs/cli check-typespnpm lintpnpm --filter @voyantjs/cli test