Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"dev": "bun run src/bin.ts",
"build": "bun run script/build.ts --single",
"build:all": "bun run script/build.ts",
"hole-punch": "bun run script/hole-punch.ts",
"bundle": "bun run script/bundle.ts",
"typecheck": "tsc --noEmit",
"lint": "bunx ultracite check",
Expand Down
12 changes: 11 additions & 1 deletion script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { promisify } from "node:util";
import { gzip } from "node:zlib";
import { $ } from "bun";
import pkg from "../package.json";
import { processBinary } from "./hole-punch.js";

const gzipAsync = promisify(gzip);

Expand Down Expand Up @@ -98,8 +99,17 @@ async function buildTarget(target: BuildTarget): Promise<boolean> {

console.log(` -> ${outfile}`);

// Hole-punch: zero unused ICU data entries so they compress to nearly nothing.
// Must run before gzip so the compressed output benefits from zeroed regions.
const hpStats = processBinary(outfile);
if (hpStats && hpStats.removedEntries > 0) {
console.log(
` -> hole-punched ${hpStats.removedEntries}/${hpStats.totalEntries} ICU entries`
);
}

// In CI, create gzip-compressed copies for release downloads.
// Reduces download size by ~60% (99 MB → 37 MB).
// With hole-punch, reduces download size by ~70% (99 MB → 28 MB).
if (process.env.CI) {
const binary = await Bun.file(outfile).arrayBuffer();
const compressed = await gzipAsync(Buffer.from(binary), { level: 6 });
Expand Down
Loading
Loading