Introducing wasmify-rails
Most of the steps required to make a Rails application Wasm-compatible are the same for all Rails applications (at least those we worked with). That means, there should be a way to automate or at least simplify the process. And here comes wasmify-rails.
Wasmify Rails is a collection of tools and extensions to speed up the process of compiling a Rails application into a Wasm module as well as the starter project to run Rails in the browser.
Read the project's Readme for the full instructions set. Let me recall the basics here:
Install the
wasmify-rails
gemRun the
bin/rails wasmify:install
command to preconfigure your applicaiton add thewasm
environmentRun the
bin/rails wasmify:pack
command to compile the app into a Wasm module (it's likely gonna fail from the first time, you need to tweak your configuration and iterate)(Optionally) Generate a PWA application to launch your app in the browser:
bin/rails wasmify:pwa
.
Besides commands to wasmify your application, Wasmify Rails also comes some useful extensions, such as Active Record database adapters, Ruby libraries shims, and so on.
You can stop here and play with wasmify-rails
, or you can continue reading the book and explore each of the challenges described above in detail.
Check out also our demo application using wasmify-rails
: rails-on-wasm-playground.