1import { build } from "esbuild";2import { readFile, mkdtemp, rm } from "node:fs/promises";3import { tmpdir } from "node:os";4import { join } from "node:path";5import { signerBundle, nostrNameBundle } from "./bundle-config.mjs";67const root = new URL("..", import.meta.url);8const temporaryDirectory = await mkdtemp(join(tmpdir(), "tinyrelay-bundles-"));9const bundles = [10 ["signer", signerBundle(join(temporaryDirectory, "signer.js")), "tinyclient/signer.js"],11 ["nostr-name", nostrNameBundle(join(temporaryDirectory, "nostr-name.js")), "tinyclient/nostr-name.js"],12];1314try {15 for (const [name, config, checkedInPath] of bundles) {16 await build(config);17 const [built, checkedIn] = await Promise.all([18 readFile(config.outfile),19 readFile(new URL(checkedInPath, root)),20 ]);21 if (!built.equals(checkedIn)) {22 throw new Error(`${checkedInPath} is stale; run npm run build:${name}`);23 }24 }25 console.log(`verified ${bundles.length} generated browser bundles`);26} finally {27 await rm(temporaryDirectory, { recursive: true, force: true });28}