// canvaskit-wasm resolves its wasm at runtime, not through the bundler, so the // binary has to be a served asset. 8MB in the repo is worse than 8MB copied out // of node_modules at build time (the Docker build stage does the same). import { copyFileSync, mkdirSync, existsSync } from 'node:fs'; import { dirname } from 'node:path'; const from = 'node_modules/canvaskit-wasm/bin/full/canvaskit.wasm'; const to = 'public/wasm/canvaskit.wasm'; if (!existsSync(from)) { console.error(`missing ${from} — run npm install first`); process.exit(1); } mkdirSync(dirname(to), { recursive: true }); copyFileSync(from, to); console.log(`copied ${from} -> ${to}`);