mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
fix(build): allow tsdown heap override
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user