Pass tree-sitter wasm bytes to Parser.init on Windows
The previous fix (d79d758d2) embedded the wasm path on process.env and
let init-node.ts resolve it via fs.existsSync. That worked on Linux/mac
but kept crashing on Windows: bun --compile reports the embedded asset
as `B:\~BUN\root\tree-sitter.wasm`, and fs.existsSync returns false for
that path even though fs.readFileSync succeeds. resolveTreeSitterWasm
fell through every branch and threw "Internal error: tree-sitter.wasm
not found".
Read the bytes once in pre-init via fs.readFileSync (which works on
Windows bunfs) and stash them on globalThis. init-node.ts now passes
them straight to Parser.init({ wasmBinary }), bypassing locateFile and
filesystem path resolution entirely.
globalThis is the cross-bundle channel: the SDK pre-built bundle inlines
its own copy of init-node.ts, so a module-level variable in this package
isn't visible to the singleton initialized via the SDK. The path-based
fallback is preserved for external SDK consumers that don't pre-load.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> J
James Grugett committed
da4f4c7917472a7a49689b4baa645b6f28e2edf4
Parent: 869e34b