Build: fail on unresolved tsdown imports

This commit is contained in:
Tak Hoffman 2026-03-18 07:57:33 -05:00
parent 79c6158ac6
commit 86e9dcfc1b
No known key found for this signature in database

View File

@ -5,6 +5,7 @@ import { spawnSync } from "node:child_process";
const logLevel = process.env.OPENCLAW_BUILD_VERBOSE ? "info" : "warn";
const extraArgs = process.argv.slice(2);
const INEFFECTIVE_DYNAMIC_IMPORT_RE = /\[INEFFECTIVE_DYNAMIC_IMPORT\]/;
const UNRESOLVED_IMPORT_RE = /\[UNRESOLVED_IMPORT\]/;
const result = spawnSync(
"pnpm",
["exec", "tsdown", "--config-loader", "unrun", "--logLevel", logLevel, ...extraArgs],
@ -31,6 +32,13 @@ if (result.status === 0 && INEFFECTIVE_DYNAMIC_IMPORT_RE.test(`${stdout}\n${stde
process.exit(1);
}
if (result.status === 0 && UNRESOLVED_IMPORT_RE.test(`${stdout}\n${stderr}`)) {
console.error(
"Build emitted [UNRESOLVED_IMPORT]. Declare or bundle the missing dependency instead of silently externalizing it.",
);
process.exit(1);
}
if (typeof result.status === "number") {
process.exit(result.status);
}