Skip to content

Commit 68ba1af

Browse files
committed
fix: Fix scripts/watch-node.mjs and use tsdown --watch.
1 parent 4b74067 commit 68ba1af

3 files changed

Lines changed: 24 additions & 14 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"docs:bin": "node scripts/build-docs-list.mjs",
8686
"docs:dev": "cd docs && mint dev",
8787
"docs:build": "cd docs && pnpm dlx --reporter append-only mint broken-links",
88-
"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",
88+
"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",
8989
"plugins:sync": "node --import tsx scripts/sync-plugin-versions.ts",
9090
"release:check": "node --import tsx scripts/release-check.ts",
9191
"ui:install": "node scripts/ui.js install",

‎scripts/watch-node.mjs‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import process from "node:process";
55
const args = process.argv.slice(2);
66
const env = { ...process.env };
77
const cwd = process.cwd();
8-
const compilerOverride = env.OPENCLAW_TS_COMPILER ?? env.CLAWDBOT_TS_COMPILER;
9-
const compiler = compilerOverride === "tsc" ? "tsc" : "tsgo";
10-
const projectArgs = ["--project", "tsconfig.json"];
118

12-
const initialBuild = spawnSync("pnpm", ["exec", compiler, ...projectArgs], {
9+
const initialBuild = spawnSync("pnpm", ["build"], {
1310
cwd,
1411
env,
1512
stdio: "inherit",
@@ -19,12 +16,7 @@ if (initialBuild.status !== 0) {
1916
process.exit(initialBuild.status ?? 1);
2017
}
2118

22-
const watchArgs =
23-
compiler === "tsc"
24-
? [...projectArgs, "--watch", "--preserveWatchOutput"]
25-
: [...projectArgs, "--watch"];
26-
27-
const compilerProcess = spawn("pnpm", ["exec", compiler, ...watchArgs], {
19+
const compilerProcess = spawn("pnpm", ["tsdown", '--watch', 'src/'], {
2820
cwd,
2921
env,
3022
stdio: "inherit",
@@ -39,7 +31,9 @@ const nodeProcess = spawn(process.execPath, ["--watch", "openclaw.mjs", ...args]
3931
let exiting = false;
4032

4133
function cleanup(code = 0) {
42-
if (exiting) return;
34+
if (exiting) {
35+
return;
36+
}
4337
exiting = true;
4438
nodeProcess.kill("SIGTERM");
4539
compilerProcess.kill("SIGTERM");
@@ -50,11 +44,15 @@ process.on("SIGINT", () => cleanup(130));
5044
process.on("SIGTERM", () => cleanup(143));
5145

5246
compilerProcess.on("exit", (code) => {
53-
if (exiting) return;
47+
if (exiting) {
48+
return;
49+
}
5450
cleanup(code ?? 1);
5551
});
5652

5753
nodeProcess.on("exit", (code, signal) => {
58-
if (signal || exiting) return;
54+
if (signal || exiting) {
55+
return;
56+
}
5957
cleanup(code ?? 1);
6058
});

‎tsdown.config.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from 'tsdown'
2+
3+
export default defineConfig([
4+
{
5+
entry: 'src/index.ts',
6+
platform: 'node',
7+
},
8+
{
9+
entry: 'src/entry.ts',
10+
platform: 'node',
11+
},
12+
])

0 commit comments

Comments
 (0)