Ruby wasm

2025-01-16 ruby

tipやknowledgeというよりは自分向けの進捗メモのような感じです…。

ブラウザでRubyを動かす方法。

<html>
  <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.7.0/dist/browser.script.iife.js"></script>
  <script type="text/ruby">
    puts "Hello, console!" # (Printed to the Web browser console)

    require "js"
    JS.global[:document].write "Hello, world!"

    IO.write("test.txt","Hello, file!")
    puts Dir.entries(".")

    # How to load external gems..?
    # require "four-pillars"
  </script>
</html>