From 1b4fc8b6110188bfd35fccdf82d76da2eecfe002 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 6 Aug 2026 11:19:05 +0800 Subject: [PATCH 1/3] perf(fmt): share compile cache with workers --- packages/rstack/bin/rs.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/rstack/bin/rs.js b/packages/rstack/bin/rs.js index a29c927f..8322998c 100755 --- a/packages/rstack/bin/rs.js +++ b/packages/rstack/bin/rs.js @@ -1,12 +1,15 @@ #!/usr/bin/env node import nodeModule from 'node:module'; -// enable on-disk code caching of all modules loaded by Node.js +// enable on-disk code caching and share its directory with child workers // requires Nodejs >= 22.8.0 const { enableCompileCache } = nodeModule; if (enableCompileCache) { try { - enableCompileCache(); + const { directory } = enableCompileCache(); + if (directory) { + process.env.NODE_COMPILE_CACHE = directory; + } } catch { // ignore errors } From 0bfd397468e263f06ae83865fc20e60f677f315b Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 6 Aug 2026 11:42:39 +0800 Subject: [PATCH 2/3] fix(fmt): preserve configured compile cache root --- packages/rstack/bin/rs.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rstack/bin/rs.js b/packages/rstack/bin/rs.js index 8322998c..6d6d8cda 100755 --- a/packages/rstack/bin/rs.js +++ b/packages/rstack/bin/rs.js @@ -3,11 +3,11 @@ import nodeModule from 'node:module'; // enable on-disk code caching and share its directory with child workers // requires Nodejs >= 22.8.0 -const { enableCompileCache } = nodeModule; +const { enableCompileCache, constants } = nodeModule; if (enableCompileCache) { try { - const { directory } = enableCompileCache(); - if (directory) { + const { directory, status } = enableCompileCache(); + if (directory && status === constants.compileCacheStatus.ENABLED) { process.env.NODE_COMPILE_CACHE = directory; } } catch { From aad7bd71ae60f8f78f3c5d4d88a179de55620800 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 6 Aug 2026 11:50:39 +0800 Subject: [PATCH 3/3] docs(fmt): explain compile cache status check --- packages/rstack/bin/rs.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/rstack/bin/rs.js b/packages/rstack/bin/rs.js index 6d6d8cda..2dd9fc9f 100755 --- a/packages/rstack/bin/rs.js +++ b/packages/rstack/bin/rs.js @@ -7,6 +7,8 @@ const { enableCompileCache, constants } = nodeModule; if (enableCompileCache) { try { const { directory, status } = enableCompileCache(); + // ALREADY_ENABLED returns the active version-specific cache directory. + // Passing it to workers would append another version directory. if (directory && status === constants.compileCacheStatus.ENABLED) { process.env.NODE_COMPILE_CACHE = directory; }