declare const Bun: { version: string; build(options: { entrypoints: string[]; outdir: string; target: "browser"; minify: boolean; sourcemap: "none"; splitting?: boolean; naming: { entry: string; chunk: string; asset: string }; }): Promise<{ success: boolean; logs: unknown[] }>; }; import { copyFile, mkdir, rm, writeFile } from "node:fs/promises"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; import { sourceManifest } from "../bundle.js"; import pkg from "../package.json" with { type: "json" }; const EXT_DIR = dirname(dirname(fileURLToPath(import.meta.url))); const STATIC_DIR = join(EXT_DIR, "static"); const BROWSER_DIR = join(EXT_DIR, "browser"); await rm(STATIC_DIR, { recursive: true, force: true }); await mkdir(STATIC_DIR, { recursive: true }); await copyFile(join(BROWSER_DIR, "index.html"), join(STATIC_DIR, "index.html")); const result = await Bun.build({ entrypoints: [join(BROWSER_DIR, "index.ts")], outdir: STATIC_DIR, target: "browser", minify: true, sourcemap: "none", splitting: true, naming: { entry: "app.[ext]", chunk: "assets/[name]-[hash].[ext]", asset: "assets/[name]-[hash].[ext]", }, }); if (!result.success) { for (const log of result.logs) console.error(log); process.exit(1); } await writeFile( join(STATIC_DIR, "manifest.json"), JSON.stringify( { bunVersion: Bun.version, packageVersions: { "@pierre/diffs": pkg.dependencies["@pierre/diffs"], "@pierre/trees": pkg.dependencies["@pierre/trees"], }, sources: await sourceManifest(), }, null, 2, ), ); console.log(`built diff-review browser bundle in ${STATIC_DIR}`);