diff --git a/src/install/install.zig b/src/install/install.zig index e9e3e1d2c1..860e91b02a 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -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(); diff --git a/test/internal/ban-words.test.ts b/test/internal/ban-words.test.ts index 3ac65c6498..a69db2e993 100644 --- a/test/internal/ban-words.test.ts +++ b/test/internal/ban-words.test.ts @@ -34,7 +34,7 @@ const words: Record [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 },