Skip to content

Toolcraft 0.0.109 SDK/MCP standalone bundles retain dynamic require("ignore") #514

Description

@kamilio

Summary

toolcraft@0.0.109 cannot produce a truly standalone ESM bundle when an application imports toolcraft/sdk or toolcraft/mcp, even when following the documented esbuild standalone recipe.

Those entry points unconditionally reach @poe-code/process-runner/dist/docker/build-context.js, which uses createRequire(import.meta.url)("ignore"). esbuild cannot statically bundle that dynamic require. The packed application therefore starts only while a separate ignore package happens to be resolvable, and fails in a clean consumer with ERR_MODULE_NOT_FOUND / Cannot find module 'ignore'.

Reproduction

  1. Install toolcraft@0.0.109 and esbuild@0.28.1.
  2. Create an entry that imports createSDK from toolcraft/sdk, or imports the MCP runner from toolcraft/mcp.
  3. Bundle it using the exact README recipe (bundle: true, format: "esm", platform: "node", target: "node18", splitting: false).
  4. Install only the resulting application package in a clean temporary consumer, without Toolcraft or ignore as runtime dependencies.
  5. Import the generated SDK bundle or start the MCP bundle.

Observed:

Error: Cannot find module 'ignore'
Require stack:
- .../dist/toolcraft.js

The emitted bundle retains code equivalent to:

const require = createRequire(import.meta.url);
const createIgnore = require("ignore");

The CLI-only path can tree-shake optional integrations, but the SDK and MCP entry points import human-in-loop / approval modules that reach process-runner even when the command tree does not configure those features.

Expected

The supported Toolcraft SDK and MCP entry points should bundle and execute in a clean consumer using Toolcraft's documented standalone esbuild recipe, without downstream packages adding an undeclared ignore runtime dependency, source rewrite, alias, shim, or custom bundler plugin.

Acceptance criteria

  • Add a fixture that bundles an app importing toolcraft/sdk and one importing toolcraft/mcp with the documented esbuild recipe.
  • Install each packed fixture in a clean consumer containing no external Toolcraft or ignore runtime package.
  • Import/start both bundles on Node.js 18.18, 20, 22, and 24.
  • Ensure unused process-runner/human-in-loop code is tree-shaken, or replace the dynamic require with a bundler-compatible supported implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions