From 90a1a4b15762306daee14a2fb0eb6165e81847ed Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Fri, 17 Jul 2026 18:34:38 -0700 Subject: [PATCH] fix(cli): emit child-process runtime worker in the published package engine's child-process-runtime forks dist/child-process-worker.js as a sibling of the bundled bin.js, but the CLI build never emitted it, so isolationMode: "child-process" could not spawn its runtime worker from any published install. Add a named tsup entry bundling the engine worker with bin.js's exact externals; verified via fork() with the runtime's spawn options (IPC handlers register, no module-resolution errors) and npm pack --dry-run listing. Co-Authored-By: Claude Fable 5 --- .changeset/ship-child-process-worker.md | 7 +++++++ packages/cli/tsup.config.ts | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .changeset/ship-child-process-worker.md diff --git a/.changeset/ship-child-process-worker.md b/.changeset/ship-child-process-worker.md new file mode 100644 index 0000000000..e24dbda5d0 --- /dev/null +++ b/.changeset/ship-child-process-worker.md @@ -0,0 +1,7 @@ +--- +"@runfusion/fusion": patch +--- + +summary: Ship the child-process runtime worker so isolationMode "child-process" works from npm installs. +category: fix +dev: New tsup entry emits dist/child-process-worker.js beside bin.js, matching the engine's getWorkerPath() sibling resolution; bundled with bin.js's noExternal/external/banner shape. diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts index 32e0ae8890..bd3926a296 100644 --- a/packages/cli/tsup.config.ts +++ b/packages/cli/tsup.config.ts @@ -368,7 +368,23 @@ function assertAllStagedBundledPluginsLoadable() { const pluginSdkEntry = join(__dirname, "..", "plugin-sdk", "src", "index.ts"); const cliBuildConfig = { - entry: ["src/bin.ts", "src/extension.ts"], + /* + * FNXC:CliPackaging 2026-07-17-21:05: + * Projects with isolationMode "child-process" fork a runtime worker that the engine's + * getWorkerPath() resolves as child-process-worker.js NEXT TO the running compiled module — + * i.e. dist/child-process-worker.js beside the bundled dist/bin.js in a published install. + * The published package never shipped that file, so child-process isolation always failed + * with ERR_MODULE_NOT_FOUND. Emit the engine worker as a sibling named entry here so it + * inherits the exact bin.js bundling shape (ESM, @fusion/* bundled via noExternal, native and + * platform-specific deps external and resolved from the installed package's node_modules, + * createRequire banner). The worker is spawned with node fork() + IPC, so it must be a plain + * Node-runnable ESM file; every external below is a published dependency of @runfusion/fusion. + */ + entry: { + bin: "src/bin.ts", + extension: "src/extension.ts", + "child-process-worker": "../engine/src/runtimes/child-process-worker.ts", + }, format: ["esm"], platform: "node", target: "node22",