- Notifications
You must be signed in to change notification settings - Fork0
ruby.wasm is a collection of WebAssembly ports of the CRuby.
License
skryukov/ruby.wasm
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
ruby.wasm is a collection of WebAssembly ports of theCRuby.It enables running Ruby application on browsers, WASI compatible WebAssembly runtimes, and Edge Computing platforms.
Try ruby.wasm inTryRuby in your browser.
Create and saveindex.html page with the following contents:
<html><scriptsrc="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.4.1/dist/browser.script.iife.js"></script><scripttype="text/ruby">require"js"putsRUBY_VERSION #=>Hello,world!(printedtothebrowserconsole)JS.global[:document].write"Hello, world!"</script></html>
Dependencies:wasi-vfs,wasmtime
#Download a prebuilt Ruby release$curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-3.2-wasm32-unknown-wasi-full.tar.gz$tar xfz ruby-3.2-wasm32-unknown-wasi-full.tar.gz#Extract ruby binary not to pack itself$mv 3.2-wasm32-unknown-wasi-full/usr/local/bin/ruby ruby.wasm#Put your app code$mkdir src$echo"puts 'Hello'"> src/my_app.rb#Pack the whole directory under /usr and your app dir$wasi-vfs pack ruby.wasm --mapdir /src::./src --mapdir /usr::./3.2-wasm32-unknown-wasi-full/usr -o my-ruby-app.wasm#Run the packed scripts$wasmtime my-ruby-app.wasm -- /src/my_app.rbHello
See theREADME.md of each package for more detail and its usage.
| Package | Description | npm |
|---|---|---|
| @ruby/3.3-wasm-wasi | CRuby 3.3 built on WASI with JS interop support | |
| @ruby/3.2-wasm-wasi | CRuby 3.2 built on WASI with JS interop support | |
| @ruby/head-wasm-wasi | HEAD CRuby built on WASI with JS interop support | |
| @ruby/head-wasm-emscripten | HEAD CRuby built on Emscripten (not well tested) |
This project distributesprebuilt Ruby binaries in GitHub Releases.Abuild is a combination of ruby version,profile, andtarget.
| Triple | Description |
|---|---|
wasm32-unknown-wasi | Targeting WASI-compatible environments (e.g. Node.js, browsers with polyfill,wasmtime, and so on) |
wasm32-unknown-emscripten | Targeting JavaScript environments including Node.js and browsers |
| Profile | Description |
|---|---|
minimal | No standard extension libraries (likejson,yaml, orstringio) |
full | All standard extension libraries |
The current WASI target build does not yet supportThread related APIs. Specifically, WASI does not yet have an API for creating and managing threads yet.
Also there is no support for networking. It is one of the goal of WASI to support networking in the future, but it is not yet implemented.
SeeCONTRIBUTING.md for how to build and test, and how to contribute to this project.Bug reports and pull requests are welcome on GitHub athttps://github.com/ruby/ruby.wasm
About
ruby.wasm is a collection of WebAssembly ports of the CRuby.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Languages
- Ruby39.6%
- C22.7%
- JavaScript16.5%
- TypeScript14.7%
- Shell3.4%
- Dockerfile1.3%
- Other1.8%