Commit 565d949
Self-heal missing tree-sitter.wasm by fetching from unpkg / jsdelivr
Round 11 shipped a binary that needs tree-sitter.wasm next to it
(bun --compile asset embedding was broken on Windows for every
mechanism we tried). The new freebuff/codebuff npm wrappers know to
extract the wasm from the release tarball next to the binary, but
the wrapper auto-updates only the binary, not itself — so users
who installed a pre-fix wrapper download the new binary, the
wrapper strips the wasm with the temp dir, and the new binary
crashes on first run.
Closing that loop in the binary itself: when init-node.ts's
locateFile fallback can't find a sibling tree-sitter.wasm, fetch it
synchronously from a CDN (unpkg, with jsdelivr as backup) and cache
it next to the binary. Subsequent runs short-circuit at the
existsSync check so the download only happens once.
Sync via execFileSync('curl', ...) because emscripten's locateFile
callback must return a path immediately. curl is built into macOS,
Linux, and Windows 10 1803+. If it isn't, we fall through to the
existing thrown error with a clear message.
WEB_TREE_SITTER_VERSION is pinned to match sdk/package.json — a wasm
built for a different web-tree-sitter runtime would crash with a
much more confusing error than "missing wasm".
Verified locally: deleted the sibling wasm, ran the binary,
download fired ("[tree-sitter] downloaded https://unpkg.com/..."),
file cached next to the binary, init succeeded; second run used the
cache and made no network calls.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 86ebd09 commit 565d949
1 file changed
Lines changed: 77 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
9 | 26 | | |
10 | 27 | | |
11 | 28 | | |
| |||
30 | 47 | | |
31 | 48 | | |
32 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
33 | 100 | | |
34 | 101 | | |
35 | 102 | | |
| |||
56 | 123 | | |
57 | 124 | | |
58 | 125 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 126 | + | |
| 127 | + | |
63 | 128 | | |
64 | 129 | | |
65 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
66 | 139 | | |
67 | 140 | | |
68 | 141 | | |
| |||
0 commit comments