You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ship tree-sitter.wasm as a sibling file next to the CLI binary
Five attempts to embed the wasm into the bun --compile binary all
failed on Windows in different ways. Each one's bytes ended up in the
binary (we verified this directly), but every JS-level retrieval
mechanism we tried got stripped by the time the runtime ran:
1. `with { type: 'file' }` of `web-tree-sitter/tree-sitter.wasm`
subpath — bytes embedded, import variable bound to undefined.
2. `with { type: 'file' }` of a copied-in relative .wasm — same as #1.
3. Single 274KB base64 string literal — got dropped by the minifier.
4. ~268 chunked base64 string literals — same fate.
5. Function-export wrapping the chunked array, with eager file write
verification on disk — chunks confirmed on disk after embed,
still not present in the compiled output.
The bun-compile-on-Windows code path is doing something destructive
to JS-source-level wasm asset references that we cannot reliably
work around from the source. So bypass the bundler entirely: ship
tree-sitter.wasm as a *sibling file* next to the binary.
- cli/scripts/build-binary.ts: copies the wasm from node_modules to
cli/bin/tree-sitter.wasm after `bun build --compile`, alongside the
binary. Drops all the embed/verify machinery from previous rounds.
- cli/src/pre-init/tree-sitter-wasm.ts: at runtime, looks for
`dirname(process.execPath)/tree-sitter.wasm`, sets the env var that
init-node.ts reads, and (best-effort) reads the bytes synchronously
to publish on globalThis for the wasmBinary fast path. Both
channels feed the same SDK init.
- cli/src/pre-init/tree-sitter-wasm-bytes.ts: deleted. No more
generated module.
- .github/workflows/cli-release-build.yml: tarball includes
`tree-sitter.wasm` next to the binary (both matrix and Windows-
specific job).
- cli/release/index.js + freebuff/cli/release/index.js: the npm
postinstall downloader now also moves tree-sitter.wasm out of the
temp extraction dir to live next to the installed binary.
Verified locally: build copies the wasm into bin/, --smoke-tree-sitter
exits 0 with "tree-sitter smoke ok (wasmBinary, 205488 bytes)", full
boot smoke passes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments