fix(build): allow tsdown heap override

This commit is contained in:
openclaw-clownfish[bot]
2026-06-22 12:22:25 +00:00
parent a75b92c29b
commit 8de57351f7
2 changed files with 13 additions and 9 deletions
+2 -9
View File
@@ -7,6 +7,7 @@ import fs from "node:fs";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { BUNDLED_PLUGIN_PATH_PREFIX } from "./lib/bundled-plugin-paths.mjs";
import { parsePositiveInt } from "./lib/numeric-options.mjs";
import { TSDOWN_PACKAGE_OUTPUT_ROOTS } from "./lib/tsdown-output-roots.mjs";
import { resolveWindowsTaskkillPath } from "./lib/windows-taskkill.mjs";
import { resolvePnpmRunner } from "./pnpm-runner.mjs";
@@ -307,15 +308,7 @@ function parsePositiveIntegerEnv(value, name) {
if (typeof value !== "string" || value.trim() === "") {
return null;
}
const text = value.trim();
if (!/^\d+$/u.test(text)) {
throw new Error(`${name} must be a positive integer`);
}
const parsed = Number(text);
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
throw new Error(`${name} must be a positive safe integer`);
}
return parsed;
return parsePositiveInt(value, name);
}
function parseNonNegativeIntegerEnv(value, name) {
+11
View File
@@ -260,6 +260,17 @@ describe("resolveTsdownBuildInvocation", () => {
expect(result.options.env.NODE_OPTIONS).toBe("--max-old-space-size=3072");
});
it("keeps memory detection when OPENCLAW_TSDOWN_MAX_OLD_SPACE_MB is blank", () => {
const result = resolveTsdownBuildInvocation({
nodeExecPath: "/usr/bin/node",
npmExecPath: "/tmp/pnpm.cjs",
env: { OPENCLAW_TSDOWN_MAX_OLD_SPACE_MB: " " },
cgroupMemoryLimitBytes: 7 * 1024 * 1024 * 1024,
});
expect(result.options.env.NODE_OPTIONS).toBe("--max-old-space-size=6400");
});
it("uses OPENCLAW_TSDOWN_MAX_OLD_SPACE_MB to normalize inherited NODE_OPTIONS", () => {
const result = resolveTsdownBuildInvocation({
platform: "win32",