From ed65131c1cb813ff396b99884dac9e789ce65a81 Mon Sep 17 00:00:00 2001 From: cpojer Date: Sat, 31 Jan 2026 17:26:39 +0900 Subject: [PATCH] fix: Also build `entry.ts` into `dist/entry.mjs`. --- openclaw.mjs | 2 +- package.json | 2 +- src/commands/status.test.ts | 4 ++-- src/daemon/program-args.test.ts | 6 +++--- src/infra/control-ui-assets.ts | 2 +- src/infra/gateway-lock.ts | 4 +--- src/infra/ports.test.ts | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/openclaw.mjs b/openclaw.mjs index 78992f94ab..a83cdc844b 100755 --- a/openclaw.mjs +++ b/openclaw.mjs @@ -11,4 +11,4 @@ if (module.enableCompileCache && !process.env.NODE_DISABLE_COMPILE_CACHE) { } } -await import("./dist/entry.js"); +await import("./dist/entry.mjs"); diff --git a/package.json b/package.json index a22a718389..03c3fdfbcd 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "docs:bin": "node scripts/build-docs-list.mjs", "docs:dev": "cd docs && mint dev", "docs:build": "cd docs && pnpm dlx --reporter append-only mint broken-links", - "build": "pnpm canvas:a2ui:bundle && tsdown && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/write-build-info.ts", + "build": "pnpm canvas:a2ui:bundle && tsdown src/index.ts src/entry.ts && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/write-build-info.ts", "plugins:sync": "node --import tsx scripts/sync-plugin-versions.ts", "release:check": "node --import tsx scripts/release-check.ts", "ui:install": "node scripts/ui.js install", diff --git a/src/commands/status.test.ts b/src/commands/status.test.ts index 7cc3f617f3..477f920c5e 100644 --- a/src/commands/status.test.ts +++ b/src/commands/status.test.ts @@ -254,7 +254,7 @@ vi.mock("../daemon/service.js", () => ({ isLoaded: async () => true, readRuntime: async () => ({ status: "running", pid: 1234 }), readCommand: async () => ({ - programArguments: ["node", "dist/entry.js", "gateway"], + programArguments: ["node", "dist/entry.mjs", "gateway"], sourcePath: "/tmp/Library/LaunchAgents/bot.molt.gateway.plist", }), }), @@ -267,7 +267,7 @@ vi.mock("../daemon/node-service.js", () => ({ isLoaded: async () => true, readRuntime: async () => ({ status: "running", pid: 4321 }), readCommand: async () => ({ - programArguments: ["node", "dist/entry.js", "node-host"], + programArguments: ["node", "dist/entry.mjs", "node-host"], sourcePath: "/tmp/Library/LaunchAgents/bot.molt.node.plist", }), }), diff --git a/src/daemon/program-args.test.ts b/src/daemon/program-args.test.ts index c5c8742b5f..1227a2443c 100644 --- a/src/daemon/program-args.test.ts +++ b/src/daemon/program-args.test.ts @@ -24,7 +24,7 @@ afterEach(() => { describe("resolveGatewayProgramArguments", () => { it("uses realpath-resolved dist entry when running via npx shim", async () => { const argv1 = path.resolve("/tmp/.npm/_npx/63c3/node_modules/.bin/openclaw"); - const entryPath = path.resolve("/tmp/.npm/_npx/63c3/node_modules/openclaw/dist/entry.js"); + const entryPath = path.resolve("/tmp/.npm/_npx/63c3/node_modules/openclaw/dist/entry.mjs"); process.argv = ["node", argv1]; fsMocks.realpath.mockResolvedValue(entryPath); fsMocks.access.mockImplementation(async (target: string) => { @@ -49,10 +49,10 @@ describe("resolveGatewayProgramArguments", () => { // Simulates pnpm global install where node_modules/openclaw is a symlink // to .pnpm/openclaw@X.Y.Z/node_modules/openclaw const symlinkPath = path.resolve( - "/Users/test/Library/pnpm/global/5/node_modules/openclaw/dist/entry.js", + "/Users/test/Library/pnpm/global/5/node_modules/openclaw/dist/entry.mjs", ); const realpathResolved = path.resolve( - "/Users/test/Library/pnpm/global/5/node_modules/.pnpm/openclaw@2026.1.21-2/node_modules/openclaw/dist/entry.js", + "/Users/test/Library/pnpm/global/5/node_modules/.pnpm/openclaw@2026.1.21-2/node_modules/openclaw/dist/entry.mjs", ); process.argv = ["node", symlinkPath]; fsMocks.realpath.mockResolvedValue(realpathResolved); diff --git a/src/infra/control-ui-assets.ts b/src/infra/control-ui-assets.ts index 867485f5cd..fc7c262d16 100644 --- a/src/infra/control-ui-assets.ts +++ b/src/infra/control-ui-assets.ts @@ -47,7 +47,7 @@ export async function resolveControlUiDistIndexPath( } const normalized = path.resolve(argv1); - // Case 1: entrypoint is directly inside dist/ (e.g., dist/entry.js) + // Case 1: entrypoint is directly inside dist/ (e.g., dist/entry.mjs) const distDir = path.dirname(normalized); if (path.basename(distDir) === "dist") { return path.join(distDir, "control-ui", "index.html"); diff --git a/src/infra/gateway-lock.ts b/src/infra/gateway-lock.ts index 44e159f181..8d83228357 100644 --- a/src/infra/gateway-lock.ts +++ b/src/infra/gateway-lock.ts @@ -74,10 +74,8 @@ function isGatewayArgv(args: string[]): boolean { const entryCandidates = [ "dist/index.mjs", - "dist/index.mjs", - "dist/entry.js", - "openclaw.mjs", "dist/entry.mjs", + "openclaw.mjs", "scripts/run-node.mjs", "src/index.ts", ]; diff --git a/src/infra/ports.test.ts b/src/infra/ports.test.ts index 9a70d049e0..c8f77c2341 100644 --- a/src/infra/ports.test.ts +++ b/src/infra/ports.test.ts @@ -37,7 +37,7 @@ describe("ports helpers", () => { expect( classifyPortListener( { - commandLine: "node /Users/me/Projects/openclaw/dist/entry.js gateway", + commandLine: "node /Users/me/Projects/openclaw/dist/entry.mjs gateway", }, 18789, ),