Commit 54c0729
Switch tree-sitter wasm embed from base64 string to
The base64-in-source approach didn't survive `bun --compile` on Windows.
The CI build's `verifyTreeSitterWasmEmbedded` step caught it:
Embedded tree-sitter.wasm from D:\a\...\tree-sitter.wasm (205488 bytes
→ 273984 chars base64)
[343ms] minify -16.58 MB
Embedded tree-sitter wasm prefix not found in D:\a\...\codebuff.exe.
So the embed step wrote the bytes to disk and bun read them, but the
274KB string literal didn't end up in the compiled output — likely
tree-shaken or transformed by the minifier on Windows. The same code
worked on macOS and Linux locally and in CI.
Switch to Bun's documented asset-embed mechanism: import the wasm with
`with { type: 'file' }`. Bun handles this through the bundler's asset
pipeline rather than as a generic string literal, and the resulting
binary contains the wasm bytes verbatim at a bunfs path.
- cli/src/pre-init/tree-sitter-wasm.ts: import the wasm path, set the
env var (for the locateFile fallback), and try a synchronous read so
Parser.init can take the wasmBinary fast path. If the read throws
(some Windows configurations have done this), log loudly so user
reports include the diagnostic, then fall through to the locateFile
flow — which init-node.ts now accepts bunfs paths through, even when
fs.existsSync misreports them.
- The --smoke-tree-sitter handler is now a top-level `await` instead
of a fire-and-forget IIFE. Without that, commander.parse() ran
synchronously in main() and failed on the unknown flag before the
smoke handler could exit cleanly.
- cli/scripts/build-binary.ts: drop the base64 stub-overwrite step
entirely. New verifyTreeSitterWasmEmbedded reads a 64-byte chunk
from the *middle* of the source wasm and asserts it appears in the
compiled binary — that proves *this specific* tree-sitter.wasm
shipped, not just any wasm (OpenTUI also embeds tree-sitter language
wasms, so a magic-bytes-only scan would false-pass).
- Delete cli/src/pre-init/tree-sitter-wasm-bytes.ts: no longer used.
Verified locally: build embeds tree-sitter.wasm via the file-attribute
import, post-build verification finds the source bytes at offset
77319353 of the compiled binary, --smoke-tree-sitter exits 0 with
"tree-sitter smoke ok (wasmBinary, 205488 bytes)".
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>with { type: 'file' }
1 parent ad6a900 commit 54c0729
3 files changed
Lines changed: 113 additions & 160 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | 148 | | |
154 | 149 | | |
155 | 150 | | |
| |||
191 | 186 | | |
192 | 187 | | |
193 | 188 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
208 | 195 | | |
209 | 196 | | |
210 | 197 | | |
| |||
225 | 212 | | |
226 | 213 | | |
227 | 214 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
234 | 221 | | |
235 | | - | |
236 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
237 | 227 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
| 228 | + | |
261 | 229 | | |
262 | 230 | | |
263 | 231 | | |
| |||
270 | 238 | | |
271 | 239 | | |
272 | 240 | | |
273 | | - | |
| 241 | + | |
274 | 242 | | |
275 | 243 | | |
276 | 244 | | |
277 | 245 | | |
278 | 246 | | |
279 | 247 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
302 | 255 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | 256 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | 257 | | |
319 | 258 | | |
320 | 259 | | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
328 | 267 | | |
329 | 268 | | |
330 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
331 | 272 | | |
332 | 273 | | |
333 | 274 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
5 | 6 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
18 | 15 | | |
19 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
33 | 51 | | |
34 | 52 | | |
35 | 53 | | |
36 | 54 | | |
37 | 55 | | |
38 | 56 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
42 | 60 | | |
43 | | - | |
44 | | - | |
| 61 | + | |
45 | 62 | | |
46 | | - | |
47 | | - | |
48 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
49 | 66 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
60 | 74 | | |
61 | | - | |
62 | 75 | | |
63 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
64 | 91 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | 92 | | |
69 | 93 | | |
70 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
71 | 99 | | |
0 commit comments