-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Description
https://github.com/ruby/ruby.wasm/tree/main/packages/npm-packages/ruby-3_2-wasm-wasi
I wanted to use the next
version, but it doesn't seem to work after 1.0.1-2023-02-10-a
. It worked until 1.0.1-2023-02-09-a
.
Work
<html>
<script src="https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@1.0.1-2023-02-09-a/dist/browser.umd.js"></script>
<script>
const { DefaultRubyVM } = window["ruby-wasm-wasi"];
const main = async () => {
// Fetch and instantiate WebAssembly binary
const response = await fetch(
// Tips: Replace the binary with debug info if you want symbolicated stack trace.
// (only nightly release for now)
// "https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@next/dist/ruby.debug+stdlib.wasm"
"https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@1.0.1-2023-02-09-a/dist/ruby.wasm"
);
const buffer = await response.arrayBuffer();
const module = await WebAssembly.compile(buffer);
const { vm } = await DefaultRubyVM(module);
vm.printVersion();
vm.eval(`
require "js"
luckiness = ["Lucky", "Unlucky"].sample
JS::eval("document.body.innerText = '#{luckiness}'")
`);
};
main();
</script>
<body></body>
</html>
Not Work
<html>
<script src="https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@1.0.1-2023-02-10-a/dist/browser.umd.js"></script>
<script>
const { DefaultRubyVM } = window["ruby-wasm-wasi"];
const main = async () => {
// Fetch and instantiate WebAssembly binary
const response = await fetch(
// Tips: Replace the binary with debug info if you want symbolicated stack trace.
// (only nightly release for now)
// "https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@next/dist/ruby.debug+stdlib.wasm"
"https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@1.0.1-2023-02-10-a/dist/ruby.wasm"
);
const buffer = await response.arrayBuffer();
const module = await WebAssembly.compile(buffer);
const { vm } = await DefaultRubyVM(module);
vm.printVersion();
vm.eval(`
require "js"
luckiness = ["Lucky", "Unlucky"].sample
JS::eval("document.body.innerText = '#{luckiness}'")
`);
};
main();
</script>
<body></body>
</html>
Metadata
Metadata
Assignees
Labels
No labels