Make node-gyp faster (#20556)

This commit is contained in:
Jarred Sumner
2025-06-24 21:07:01 -07:00
committed by GitHub
parent 2072fa1d59
commit ba126fb330
2 changed files with 12 additions and 1 deletions

View File

@@ -10178,6 +10178,17 @@ pub const PackageManager = struct {
this_transpiler.env.map.put("PATH", PATH.items) catch unreachable;
// Run node-gyp jobs in parallel.
// https://github.com/nodejs/node-gyp/blob/7d883b5cf4c26e76065201f85b0be36d5ebdcc0e/lib/build.js#L150-L184
const thread_count = bun.getThreadCount();
if (thread_count > 2) {
if (!this_transpiler.env.has("JOBS")) {
var int_buf: [10]u8 = undefined;
const jobs_str = std.fmt.bufPrint(&int_buf, "{d}", .{thread_count}) catch unreachable;
this_transpiler.env.map.putAllocValue(bun.default_allocator, "JOBS", jobs_str) catch unreachable;
}
}
const envp = try this_transpiler.env.map.createNullDelimitedEnvMap(this.allocator);
try this_transpiler.env.map.put("PATH", original_path);
PATH.deinit();

View File

@@ -34,7 +34,7 @@ const words: Record<string, { reason: string; limit?: number; regex?: boolean }>
[String.raw`: [a-zA-Z0-9_\.\*\?\[\]\(\)]+ = undefined,`]: { reason: "Do not default a struct field to undefined", limit: 242, regex: true },
"usingnamespace": { reason: "Zig 0.15 will remove `usingnamespace`" },
"catch unreachable": { reason: "For out-of-memory, prefer 'catch bun.outOfMemory()'", limit: 1859 },
"catch unreachable": { reason: "For out-of-memory, prefer 'catch bun.outOfMemory()'", limit: 1861 },
"std.fs.Dir": { reason: "Prefer bun.sys + bun.FD instead of std.fs", limit: 179 },
"std.fs.cwd": { reason: "Prefer bun.FD.cwd()", limit: 102 },