/** * Vitest global setup of every suite that runs the core: refuses to run on a missing or * stale module instead of skipping (R2 plan rev 2). The stamp is the hash of the Rust * sources the module is compiled from (scripts/wasm-stamp.mjs), written by * `pnpm wasm:build` into both builds. */ import { existsSync, readFileSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { wasmStamp } from '../../../scripts/wasm-stamp.mjs' export default function checkCoreBuilds(): void { const expected = wasmStamp() for (const build of ['pkg', 'pkg-proofs']) { const file = fileURLToPath( new URL(`../${build}/BUILD_STAMP`, import.meta.url), ) const found = existsSync(file) ? readFileSync(file, 'utf8').trim() : null if (found !== expected) { throw new Error( `packages/core-wasm/${build} is ${found ? 'stale' : 'missing'}: run \`pnpm wasm:build\``, ) } } }