mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-18 13:53:01 +08:00
fix(windows): the kernel-parity sweep loads the engine as file:// URLs (#2352)
scripts/kernel-parity.mjs handed import() a path from path.join(). On Windows that is `C:\...`, which Node's ESM loader rejects with ERR_UNSUPPORTED_ESM_URL_SCHEME, so the sweep could not run there at all and contributors kept patched scratch copies. The three engine imports now go through pathToFileURL(...).href, as the agent-eval probe scripts already do. On macOS and Linux an ordinary path resolves to the same file:// URL as before. Checked on Windows 11 after npm ci, npm run build and scripts/build-kernel.sh: the unmodified script threw at its first import; with the fix, the C# fixtures (3/3), src/search (4/4), all of src/ as TypeScript (261/263, 2 deferred to wasm) and every fixture language (42/42) run to the summary line and exit 0. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||||
|
|
||||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||||
const dist = (p) => path.join(ROOT, 'dist', p);
|
const dist = (p) => path.join(ROOT, 'dist', p);
|
||||||
@@ -106,9 +106,11 @@ if (files.length === 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- load the built engine ---------------------------------------------------
|
// --- load the built engine ---------------------------------------------------
|
||||||
const { extractFromSource } = await import(dist('extraction/tree-sitter.js'));
|
// As file:// URLs: import() rejects a bare `C:\...` path on Windows
|
||||||
const { initGrammars, loadGrammarsForLanguages, detectLanguage } = await import(dist('extraction/grammars.js'));
|
// (ERR_UNSUPPORTED_ESM_URL_SCHEME).
|
||||||
const kernel = await import(dist('extraction/kernel/index.js'));
|
const { extractFromSource } = await import(pathToFileURL(dist('extraction/tree-sitter.js')).href);
|
||||||
|
const { initGrammars, loadGrammarsForLanguages, detectLanguage } = await import(pathToFileURL(dist('extraction/grammars.js')).href);
|
||||||
|
const kernel = await import(pathToFileURL(dist('extraction/kernel/index.js')).href);
|
||||||
|
|
||||||
await initGrammars();
|
await initGrammars();
|
||||||
await loadGrammarsForLanguages([...KERNEL_LANGS]);
|
await loadGrammarsForLanguages([...KERNEL_LANGS]);
|
||||||
|
|||||||
Reference in New Issue
Block a user