// Bundles one TypeScript entry file and everything it imports into a single // .mjs that plain Node can run anywhere, for trying library code against a // real console from a machine that does not have this project checked out. // // node scripts/dev-bundle.mjs path/to/entry.ts out.mjs // // iced-x86 (the disassembler) is left as an import, because it loads a // WebAssembly file from beside itself. import path from 'node:path'; import { rolldown } from 'rolldown'; const [entry, out] = process.argv.slice(2); if (!entry || !out) { console.error('Usage: node scripts/dev-bundle.mjs '); process.exit(1); } const bundle = await rolldown({ input: path.resolve(entry), platform: 'node', external: ['iced-x86'], logLevel: 'warn' }); await bundle.write({ file: path.resolve(out), format: 'esm', codeSplitting: false }); await bundle.close(); console.log(`Bundled ${entry} -> ${out}`);