fix: Also build entry.ts into dist/entry.mjs.

This commit is contained in:
cpojer
2026-01-31 17:26:39 +09:00
parent 1766cd4123
commit ed65131c1c
7 changed files with 10 additions and 12 deletions

View File

@@ -11,4 +11,4 @@ if (module.enableCompileCache && !process.env.NODE_DISABLE_COMPILE_CACHE) {
} }
} }
await import("./dist/entry.js"); await import("./dist/entry.mjs");

View File

@@ -85,7 +85,7 @@
"docs:bin": "node scripts/build-docs-list.mjs", "docs:bin": "node scripts/build-docs-list.mjs",
"docs:dev": "cd docs && mint dev", "docs:dev": "cd docs && mint dev",
"docs:build": "cd docs && pnpm dlx --reporter append-only mint broken-links", "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", "plugins:sync": "node --import tsx scripts/sync-plugin-versions.ts",
"release:check": "node --import tsx scripts/release-check.ts", "release:check": "node --import tsx scripts/release-check.ts",
"ui:install": "node scripts/ui.js install", "ui:install": "node scripts/ui.js install",

View File

@@ -254,7 +254,7 @@ vi.mock("../daemon/service.js", () => ({
isLoaded: async () => true, isLoaded: async () => true,
readRuntime: async () => ({ status: "running", pid: 1234 }), readRuntime: async () => ({ status: "running", pid: 1234 }),
readCommand: async () => ({ readCommand: async () => ({
programArguments: ["node", "dist/entry.js", "gateway"], programArguments: ["node", "dist/entry.mjs", "gateway"],
sourcePath: "/tmp/Library/LaunchAgents/bot.molt.gateway.plist", sourcePath: "/tmp/Library/LaunchAgents/bot.molt.gateway.plist",
}), }),
}), }),
@@ -267,7 +267,7 @@ vi.mock("../daemon/node-service.js", () => ({
isLoaded: async () => true, isLoaded: async () => true,
readRuntime: async () => ({ status: "running", pid: 4321 }), readRuntime: async () => ({ status: "running", pid: 4321 }),
readCommand: async () => ({ readCommand: async () => ({
programArguments: ["node", "dist/entry.js", "node-host"], programArguments: ["node", "dist/entry.mjs", "node-host"],
sourcePath: "/tmp/Library/LaunchAgents/bot.molt.node.plist", sourcePath: "/tmp/Library/LaunchAgents/bot.molt.node.plist",
}), }),
}), }),

View File

@@ -24,7 +24,7 @@ afterEach(() => {
describe("resolveGatewayProgramArguments", () => { describe("resolveGatewayProgramArguments", () => {
it("uses realpath-resolved dist entry when running via npx shim", async () => { 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 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]; process.argv = ["node", argv1];
fsMocks.realpath.mockResolvedValue(entryPath); fsMocks.realpath.mockResolvedValue(entryPath);
fsMocks.access.mockImplementation(async (target: string) => { fsMocks.access.mockImplementation(async (target: string) => {
@@ -49,10 +49,10 @@ describe("resolveGatewayProgramArguments", () => {
// Simulates pnpm global install where node_modules/openclaw is a symlink // Simulates pnpm global install where node_modules/openclaw is a symlink
// to .pnpm/openclaw@X.Y.Z/node_modules/openclaw // to .pnpm/openclaw@X.Y.Z/node_modules/openclaw
const symlinkPath = path.resolve( 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( 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]; process.argv = ["node", symlinkPath];
fsMocks.realpath.mockResolvedValue(realpathResolved); fsMocks.realpath.mockResolvedValue(realpathResolved);

View File

@@ -47,7 +47,7 @@ export async function resolveControlUiDistIndexPath(
} }
const normalized = path.resolve(argv1); 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); const distDir = path.dirname(normalized);
if (path.basename(distDir) === "dist") { if (path.basename(distDir) === "dist") {
return path.join(distDir, "control-ui", "index.html"); return path.join(distDir, "control-ui", "index.html");

View File

@@ -74,10 +74,8 @@ function isGatewayArgv(args: string[]): boolean {
const entryCandidates = [ const entryCandidates = [
"dist/index.mjs", "dist/index.mjs",
"dist/index.mjs",
"dist/entry.js",
"openclaw.mjs",
"dist/entry.mjs", "dist/entry.mjs",
"openclaw.mjs",
"scripts/run-node.mjs", "scripts/run-node.mjs",
"src/index.ts", "src/index.ts",
]; ];

View File

@@ -37,7 +37,7 @@ describe("ports helpers", () => {
expect( expect(
classifyPortListener( classifyPortListener(
{ {
commandLine: "node /Users/me/Projects/openclaw/dist/entry.js gateway", commandLine: "node /Users/me/Projects/openclaw/dist/entry.mjs gateway",
}, },
18789, 18789,
), ),