Files
openclaude/bin/node-compile-cache.mjs
T
BogdanandGitHub d427a4b2bb perf(cli): enable Node module compile cache (#2092)
* perf(cli): enable Node module compile cache

Warm CLI invocations spend substantial time compiling the bundled ESM entrypoint. Enable Node's optional on-disk compile cache only in the process that imports the bundle, while preserving early Node 22 compatibility and making cache failures non-fatal.

Add deterministic launcher coverage, packaging checks, and a reproducible benchmark procedure so the startup benefit can be measured without flaky CI thresholds.

* fix(ci): isolate minimum Node launcher check

The full validation suite depends on knip and oxc-parser behavior unavailable in Node 22.0.0. Keep full CI on the active Node 22 line and exercise the declared runtime floor in a dedicated build-and-launch job.

* fix(benchmark): harden startup measurements

Keep environment setup outside the timed process window, document the API's Node 22.8 floor, and preserve completed benchmark results when git metadata is unavailable.

* test(cli): verify compile cache disable behavior

Pair NODE_DISABLE_COMPILE_CACHE with a temporary cache directory and assert that supported Node releases leave it empty while preserving normal launcher output.
2026-08-07 09:55:01 +08:00

18 lines
443 B
JavaScript

import * as nodeModule from 'node:module'
/** @typedef {{ enableCompileCache?: () => unknown }} CompileCacheModule */
/**
* @param {CompileCacheModule} [module=nodeModule]
*/
export function enableNodeCompileCacheIfAvailable(module = nodeModule) {
const enable = module.enableCompileCache
if (typeof enable !== 'function') return
try {
enable()
} catch {
// Compile caching is optional and must never block startup.
}
}