mirror of
https://github.com/Gitlawb/openclaude.git
synced 2026-08-24 10:14:19 -05:00
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.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
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.
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import { existsSync } from 'fs'
|
||||
import { join, dirname } from 'path'
|
||||
import { fileURLToPath, pathToFileURL } from 'url'
|
||||
import { spawnSync } from 'child_process'
|
||||
import { enableNodeCompileCacheIfAvailable } from './node-compile-cache.mjs'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const distPath = join(__dirname, '..', 'dist', 'cli.mjs')
|
||||
@@ -107,6 +108,7 @@ function relaunchWithLongSessionHeapIfNeeded() {
|
||||
|
||||
if (existsSync(distPath)) {
|
||||
relaunchWithLongSessionHeapIfNeeded()
|
||||
enableNodeCompileCacheIfAvailable()
|
||||
await import(pathToFileURL(distPath).href)
|
||||
} else {
|
||||
console.error(`
|
||||
|
||||
Reference in New Issue
Block a user