diff --git a/packages/cli/script/app-assets.ts b/packages/cli/script/app-assets.ts index 4af206447b6e..0af7aa19c42c 100644 --- a/packages/cli/script/app-assets.ts +++ b/packages/cli/script/app-assets.ts @@ -1,6 +1,7 @@ import { $ } from "bun" import path from "node:path" -import { brotliCompressSync, constants } from "node:zlib" +import { promisify } from "node:util" +import { brotliCompress, constants } from "node:zlib" import { AppArchive } from "../src/app-archive" import { collectFiles } from "./files" @@ -19,14 +20,16 @@ export async function buildAppArchive(channel: string, options?: { skipBuild?: b .map(async (key) => { const body = Buffer.from(await Bun.file(path.join(root, "dist", key)).arrayBuffer()) // Independent entries let the server materialize only assets the browser requests. - return [key, compress(body)] as const + return [key, await compress(body)] as const }), ), ) } +// The assets compress once per release, so they take brotli's best quality: about 11% smaller than quality 6 for the +// web UI. Each runs on the thread pool, which keeps the build to about a minute. function compress(body: Buffer) { - return brotliCompressSync(body, { - params: { [constants.BROTLI_PARAM_QUALITY]: 6 }, + return promisify(brotliCompress)(body, { + params: { [constants.BROTLI_PARAM_QUALITY]: 11, [constants.BROTLI_PARAM_SIZE_HINT]: body.length }, }) }