Commit 02d192f
authored
feat(build): add hole-punch tool to reduce compressed binary size (#245)
## Summary
- Adds `script/hole-punch.ts` — a post-compile tool that zeros unused
ICU data entries inside Bun-compiled binaries, making zeroed regions
compress to nearly nothing
- Reduces gzip download size by ~24% (37 MB -> 28 MB) across all
platforms
- Runs automatically in CI after build, before smoke test
## How it works
The Bun runtime embeds a 29 MB ICU data blob for international locale
support. Most entries (legacy charset converters, CJK dictionaries,
non-English locale data) are unused by a CLI tool. The tool scans for
the ICU blob via magic bytes, parses its TOC, and zeros safe-to-remove
entries while preserving root-level data, normalization files, and
English locale data that Bun accesses at startup/shutdown.
## Changes
- `script/hole-punch.ts` — hole-punch tool with modular exports for
testing
- `test/lib/hole-punch.test.ts` — 22 unit tests with synthetic ICU blob
builder
- `.github/workflows/ci.yml` — added hole-punch step after build
- `package.json` — added `hole-punch` script1 parent 74a0642 commit 02d192f
File tree
4 files changed
+1190
-1
lines changed- script
- test/lib
4 files changed
+1190
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
101 | 111 | | |
102 | | - | |
| 112 | + | |
103 | 113 | | |
104 | 114 | | |
105 | 115 | | |
| |||
0 commit comments