fix: Fix `scripts/watch-node.mjs` and use `tsdown --watch`.
parent
4b7406719c
commit
68ba1afb34
|
|
@ -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 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",
|
||||
"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",
|
||||
"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",
|
||||
|
|
|
|||
|
|
@ -5,11 +5,8 @@ import process from "node:process";
|
|||
const args = process.argv.slice(2);
|
||||
const env = { ...process.env };
|
||||
const cwd = process.cwd();
|
||||
const compilerOverride = env.OPENCLAW_TS_COMPILER ?? env.CLAWDBOT_TS_COMPILER;
|
||||
const compiler = compilerOverride === "tsc" ? "tsc" : "tsgo";
|
||||
const projectArgs = ["--project", "tsconfig.json"];
|
||||
|
||||
const initialBuild = spawnSync("pnpm", ["exec", compiler, ...projectArgs], {
|
||||
const initialBuild = spawnSync("pnpm", ["build"], {
|
||||
cwd,
|
||||
env,
|
||||
stdio: "inherit",
|
||||
|
|
@ -19,12 +16,7 @@ if (initialBuild.status !== 0) {
|
|||
process.exit(initialBuild.status ?? 1);
|
||||
}
|
||||
|
||||
const watchArgs =
|
||||
compiler === "tsc"
|
||||
? [...projectArgs, "--watch", "--preserveWatchOutput"]
|
||||
: [...projectArgs, "--watch"];
|
||||
|
||||
const compilerProcess = spawn("pnpm", ["exec", compiler, ...watchArgs], {
|
||||
const compilerProcess = spawn("pnpm", ["tsdown", '--watch', 'src/'], {
|
||||
cwd,
|
||||
env,
|
||||
stdio: "inherit",
|
||||
|
|
@ -39,7 +31,9 @@ const nodeProcess = spawn(process.execPath, ["--watch", "openclaw.mjs", ...args]
|
|||
let exiting = false;
|
||||
|
||||
function cleanup(code = 0) {
|
||||
if (exiting) return;
|
||||
if (exiting) {
|
||||
return;
|
||||
}
|
||||
exiting = true;
|
||||
nodeProcess.kill("SIGTERM");
|
||||
compilerProcess.kill("SIGTERM");
|
||||
|
|
@ -50,11 +44,15 @@ process.on("SIGINT", () => cleanup(130));
|
|||
process.on("SIGTERM", () => cleanup(143));
|
||||
|
||||
compilerProcess.on("exit", (code) => {
|
||||
if (exiting) return;
|
||||
if (exiting) {
|
||||
return;
|
||||
}
|
||||
cleanup(code ?? 1);
|
||||
});
|
||||
|
||||
nodeProcess.on("exit", (code, signal) => {
|
||||
if (signal || exiting) return;
|
||||
if (signal || exiting) {
|
||||
return;
|
||||
}
|
||||
cleanup(code ?? 1);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
import { defineConfig } from 'tsdown'
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
entry: 'src/index.ts',
|
||||
platform: 'node',
|
||||
},
|
||||
{
|
||||
entry: 'src/entry.ts',
|
||||
platform: 'node',
|
||||
},
|
||||
])
|
||||
Loading…
Reference in New Issue