In the cheat sheet, this line is used:
const binary = await fs.readFile("./node_modules/@ruby/3.2-wasm-wasi/dist/ruby.wasm");
That's a bit flaky and would break if you moved this file elsewhere.
Would it be possible to export a WASM_FILE_PATH from @ruby/3.2-wasm-wasi and @ruby/head-wasm-wasi such that it is a resolved absolute path to the Wasm binary?
The NodeJS cheat sheet would then look like this:
import fs from "fs/promises";
import { DefaultRubyVM } from "@ruby/wasm-wasi/dist/node";
import { WASM_FILE_PATH } from "@ruby/3.2-wasm-wasi"; // or from "@ruby/head-wasm-wasi"
const binary = await fs.readFile(WASM_FILE_PATH);
const module = await WebAssembly.compile(binary);
const { vm } = await DefaultRubyVM(module);
vm.eval(`puts "hello world"`);
Could this be considered?