From e0971a103141815a0f3a44930603ad490361491b Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Sat, 21 Mar 2026 01:27:03 +0900 Subject: [PATCH] perf(cli): Propagate compile cache to child_process workers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The existing enableCompileCache() in bin/repomix.cjs only applied to the main process. Tinypool child_process workers (defaultAction) were spawned without compile cache because NODE_COMPILE_CACHE env var was not set. Capture the cache directory from enableCompileCache()'s return value and set it as NODE_COMPILE_CACHE env var so child_process workers inherit it at startup — before any ESM static imports are resolved. Note: worker_threads workers (fileProcess, securityCheck, calculateMetrics) already benefit from the main process's enableCompileCache() call since they share the same V8 isolate. Co-Authored-By: Claude Opus 4.6 (1M context) --- bin/repomix.cjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/repomix.cjs b/bin/repomix.cjs index 96a8cafc9..2de42db45 100755 --- a/bin/repomix.cjs +++ b/bin/repomix.cjs @@ -1,10 +1,16 @@ #!/usr/bin/env node // https://nodejs.org/api/module.html#module-compile-cache +// Enable compile cache for the main process and propagate the cache directory +// via NODE_COMPILE_CACHE env var so child_process workers inherit it at startup +// (before any modules are loaded), which is critical for ESM static imports. const nodeModule = require('node:module'); if (nodeModule.enableCompileCache && !process.env.NODE_DISABLE_COMPILE_CACHE) { try { - nodeModule.enableCompileCache(); + const result = nodeModule.enableCompileCache(); + if (result && result.directory && !process.env.NODE_COMPILE_CACHE) { + process.env.NODE_COMPILE_CACHE = result.directory; + } } catch { // Ignore errors }