Skip to content

Export WASM_FILE_PATH from @ruby/3.2-wasm-wasi and @ruby/head-wasm-wasi #338

@terrablue

Description

@terrablue

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions