From 9dad55e334a5fb064962ba4ab4c505a3f8b07f04 Mon Sep 17 00:00:00 2001 From: carlos-alm <127798846+carlos-alm@users.noreply.github.com> Date: Thu, 26 Mar 2026 01:25:11 -0600 Subject: [PATCH] fix(bench): use dist/ for npm benchmark installs to avoid Node type-stripping error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The prior fix (#612) resolved .js→.ts in srcImport, but Node 22 throws ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING when importing .ts from node_modules. Since v3.4.0+ publishes compiled JS in dist/, use that directory instead of src/ for npm-installed benchmarks. Also replace the embedding benchmark's manual cli.ts invocation with npx codegraph, which uses the package's bin entry point. --- .github/workflows/benchmark.yml | 4 +--- scripts/lib/bench-config.ts | 7 +++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 940a03b9..336846df 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -236,9 +236,7 @@ jobs: - name: Build graph if: steps.existing.outputs.skip != 'true' - run: | - STRIP_FLAG=$(node -e "const [M]=process.versions.node.split('.').map(Number); console.log(M>=23?'--strip-types':'--experimental-strip-types')") - node $STRIP_FLAG --import ./scripts/ts-resolve-loader.js src/cli.ts build . + run: npx codegraph build . - name: Run embedding benchmark if: steps.existing.outputs.skip != 'true' diff --git a/scripts/lib/bench-config.ts b/scripts/lib/bench-config.ts index 613224b2..6dfc0e11 100644 --- a/scripts/lib/bench-config.ts +++ b/scripts/lib/bench-config.ts @@ -155,11 +155,14 @@ export async function resolveBenchmarkSource() { console.error(`Warning: failed to install @huggingface/transformers: ${err.message}`); } - const srcDir = path.join(pkgDir, 'src'); + // v3.4.0+ publishes compiled JS in dist/ alongside raw TS in src/. + // Node cannot strip types from node_modules, so prefer dist/ when available. + const distDir = path.join(pkgDir, 'dist'); + const srcDir = fs.existsSync(distDir) ? distDir : path.join(pkgDir, 'src'); if (!fs.existsSync(srcDir)) { fs.rmSync(tmpDir, { recursive: true, force: true }); - throw new Error(`Installed package does not contain src/ at ${srcDir}`); + throw new Error(`Installed package does not contain dist/ or src/ at ${pkgDir}`); } const resolvedVersion = cliVersion || installedPkg.version;