chore: Switch from TypeScript to build with tsdown, speeds up pnpm build by 5-10x.

This commit is contained in:
cpojer
2026-01-31 15:25:06 +09:00
parent d2a852b982
commit 67945e8d62
25 changed files with 553 additions and 234 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ describe("ensureSkillsWatcher", () => {
expect(ignored.some((re) => re.test("/tmp/workspace/skills/node_modules/pkg/index.js"))).toBe(
true,
);
expect(ignored.some((re) => re.test("/tmp/workspace/skills/dist/index.js"))).toBe(true);
expect(ignored.some((re) => re.test("/tmp/workspace/skills/dist/index.mjs"))).toBe(true);
expect(ignored.some((re) => re.test("/tmp/workspace/skills/.git/config"))).toBe(true);
expect(ignored.some((re) => re.test("/tmp/.hidden/skills/index.md"))).toBe(false);
});
+1 -1
View File
@@ -67,7 +67,7 @@ describe("resolveGatewayProgramArguments", () => {
it("falls back to node_modules package dist when .bin path is not resolved", async () => {
const argv1 = path.resolve("/tmp/.npm/_npx/63c3/node_modules/.bin/openclaw");
const indexPath = path.resolve("/tmp/.npm/_npx/63c3/node_modules/openclaw/dist/index.js");
const indexPath = path.resolve("/tmp/.npm/_npx/63c3/node_modules/openclaw/dist/index.mjs");
process.argv = ["node", argv1];
fsMocks.realpath.mockRejectedValue(new Error("no realpath"));
fsMocks.access.mockImplementation(async (target: string) => {
+1 -1
View File
@@ -69,7 +69,7 @@ function isGatewayArgv(args: string[]): boolean {
if (!normalized.includes("gateway")) return false;
const entryCandidates = [
"dist/index.js",
"dist/index.mjs",
"dist/index.mjs",
"dist/entry.js",
"openclaw.mjs",
+5 -5
View File
@@ -6,8 +6,8 @@ describe("isMainModule", () => {
it("returns true when argv[1] matches current file", () => {
expect(
isMainModule({
currentFile: "/repo/dist/index.js",
argv: ["node", "/repo/dist/index.js"],
currentFile: "/repo/dist/index.mjs",
argv: ["node", "/repo/dist/index.mjs"],
cwd: "/repo",
env: {},
}),
@@ -17,10 +17,10 @@ describe("isMainModule", () => {
it("returns true under PM2 when pm_exec_path matches current file", () => {
expect(
isMainModule({
currentFile: "/repo/dist/index.js",
currentFile: "/repo/dist/index.mjs",
argv: ["node", "/pm2/lib/ProcessContainerFork.js"],
cwd: "/repo",
env: { pm_exec_path: "/repo/dist/index.js", pm_id: "0" },
env: { pm_exec_path: "/repo/dist/index.mjs", pm_id: "0" },
}),
).toBe(true);
});
@@ -28,7 +28,7 @@ describe("isMainModule", () => {
it("returns false when running under PM2 but this module is imported", () => {
expect(
isMainModule({
currentFile: "/repo/node_modules/openclaw/dist/index.js",
currentFile: "/repo/node_modules/openclaw/dist/index.mjs",
argv: ["node", "/repo/app.js"],
cwd: "/repo",
env: { pm_exec_path: "/repo/app.js", pm_id: "0" },
+26 -11
View File
@@ -98,7 +98,7 @@ describe("installPluginFromArchive", () => {
JSON.stringify({
name: "@openclaw/voice-call",
version: "0.0.1",
openclaw: { extensions: ["./dist/index.js"] },
openclaw: { extensions: ["./dist/index.mjs"] },
}),
"utf-8",
);
@@ -112,7 +112,10 @@ describe("installPluginFromArchive", () => {
const extensionsDir = path.join(stateDir, "extensions");
const { installPluginFromArchive } = await import("./install.js");
const result = await installPluginFromArchive({ archivePath, extensionsDir });
const result = await installPluginFromArchive({
archivePath,
extensionsDir,
});
expect(result.ok).toBe(true);
if (!result.ok) return;
expect(result.pluginId).toBe("voice-call");
@@ -131,7 +134,7 @@ describe("installPluginFromArchive", () => {
JSON.stringify({
name: "@openclaw/voice-call",
version: "0.0.1",
openclaw: { extensions: ["./dist/index.js"] },
openclaw: { extensions: ["./dist/index.mjs"] },
}),
"utf-8",
);
@@ -145,8 +148,14 @@ describe("installPluginFromArchive", () => {
const extensionsDir = path.join(stateDir, "extensions");
const { installPluginFromArchive } = await import("./install.js");
const first = await installPluginFromArchive({ archivePath, extensionsDir });
const second = await installPluginFromArchive({ archivePath, extensionsDir });
const first = await installPluginFromArchive({
archivePath,
extensionsDir,
});
const second = await installPluginFromArchive({
archivePath,
extensionsDir,
});
expect(first.ok).toBe(true);
expect(second.ok).toBe(false);
@@ -165,16 +174,19 @@ describe("installPluginFromArchive", () => {
JSON.stringify({
name: "@openclaw/zipper",
version: "0.0.1",
openclaw: { extensions: ["./dist/index.js"] },
openclaw: { extensions: ["./dist/index.mjs"] },
}),
);
zip.file("package/dist/index.js", "export {};");
zip.file("package/dist/index.mjs", "export {};");
const buffer = await zip.generateAsync({ type: "nodebuffer" });
fs.writeFileSync(archivePath, buffer);
const extensionsDir = path.join(stateDir, "extensions");
const { installPluginFromArchive } = await import("./install.js");
const result = await installPluginFromArchive({ archivePath, extensionsDir });
const result = await installPluginFromArchive({
archivePath,
extensionsDir,
});
expect(result.ok).toBe(true);
if (!result.ok) return;
@@ -194,7 +206,7 @@ describe("installPluginFromArchive", () => {
JSON.stringify({
name: "@openclaw/voice-call",
version: "0.0.1",
openclaw: { extensions: ["./dist/index.js"] },
openclaw: { extensions: ["./dist/index.mjs"] },
}),
"utf-8",
);
@@ -212,7 +224,7 @@ describe("installPluginFromArchive", () => {
JSON.stringify({
name: "@openclaw/voice-call",
version: "0.0.2",
openclaw: { extensions: ["./dist/index.js"] },
openclaw: { extensions: ["./dist/index.mjs"] },
}),
"utf-8",
);
@@ -263,7 +275,10 @@ describe("installPluginFromArchive", () => {
const extensionsDir = path.join(stateDir, "extensions");
const { installPluginFromArchive } = await import("./install.js");
const result = await installPluginFromArchive({ archivePath, extensionsDir });
const result = await installPluginFromArchive({
archivePath,
extensionsDir,
});
expect(result.ok).toBe(false);
if (result.ok) return;
expect(result.error).toContain("openclaw.extensions");