mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
lazy load these requires so that node:cluster imports faster (#14291)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
const net = require("node:net");
|
||||
const { append, init, isEmpty, peek, remove } = require("internal/linkedlist");
|
||||
const { kHandle } = require("internal/shared");
|
||||
|
||||
let net;
|
||||
|
||||
const sendHelper = $newZigFunction("node_cluster_binding.zig", "sendHelperPrimary", 4);
|
||||
|
||||
const ArrayIsArray = Array.isArray;
|
||||
@@ -20,6 +21,7 @@ export default class RoundRobinHandle {
|
||||
server;
|
||||
|
||||
constructor(key, address, { port, fd, flags, backlog, readableAll, writableAll }) {
|
||||
net ??= require("node:net");
|
||||
this.key = key;
|
||||
this.all = new Map();
|
||||
this.free = new Map();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const EventEmitter = require("node:events");
|
||||
const child_process = require("node:child_process");
|
||||
const Worker = require("internal/cluster/Worker");
|
||||
const RoundRobinHandle = require("internal/cluster/RoundRobinHandle");
|
||||
const path = require("node:path");
|
||||
@@ -8,6 +7,8 @@ const { throwNotImplemented, kHandle } = require("internal/shared");
|
||||
const sendHelper = $newZigFunction("node_cluster_binding.zig", "sendHelperPrimary", 4);
|
||||
const onInternalMessage = $newZigFunction("node_cluster_binding.zig", "onInternalMessagePrimary", 3);
|
||||
|
||||
let child_process;
|
||||
|
||||
const ArrayPrototypeSlice = Array.prototype.slice;
|
||||
const ObjectValues = Object.values;
|
||||
const ObjectKeys = Object.keys;
|
||||
@@ -86,6 +87,7 @@ function createWorkerProcess(id, env) {
|
||||
// ArrayPrototypePush(execArgv, `--inspect-port=${getInspectPort(cluster.settings.inspectPort)}`);
|
||||
// }
|
||||
|
||||
child_process ??= require("node:child_process");
|
||||
return child_process.fork(cluster.settings.exec, cluster.settings.args, {
|
||||
cwd: cluster.settings.cwd,
|
||||
env: workerEnv,
|
||||
|
||||
Reference in New Issue
Block a user