mirror of
https://github.com/Gitlawb/openclaude.git
synced 2026-08-24 02:34:15 -05:00
* 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.
25 lines
951 B
JavaScript
25 lines
951 B
JavaScript
import { appendFileSync } from 'node:fs'
|
|
import { createRequire, syncBuiltinESMExports } from 'node:module'
|
|
|
|
const markerPath = process.env.OPENCLAUDE_TEST_COMPILE_CACHE_MARKER
|
|
const behavior = process.env.OPENCLAUDE_TEST_COMPILE_CACHE_BEHAVIOR
|
|
const builtinModule = createRequire(import.meta.url)('node:module')
|
|
|
|
if (behavior === 'absent') {
|
|
builtinModule.enableCompileCache = undefined
|
|
} else if (typeof builtinModule.enableCompileCache === 'function') {
|
|
builtinModule.enableCompileCache = () => {
|
|
if (markerPath) {
|
|
appendFileSync(markerPath, `${JSON.stringify({
|
|
pid: process.pid,
|
|
heapRelaunched: process.env.OPENCLAUDE_HEAP_RELAUNCHED === '1',
|
|
})}\n`)
|
|
}
|
|
if (behavior === 'throw') throw new Error('injected compile-cache failure')
|
|
if (behavior === 'failed-status') return { status: 0, message: 'injected failure' }
|
|
return { status: 1, directory: '/injected/cache' }
|
|
}
|
|
}
|
|
|
|
syncBuiltinESMExports()
|