homura-runtime

Core Ruby + Module Worker glue for Opal on Cloudflare Workers. This gem does not depend on Sinatra or Sequel; those live in sibling gems.

What you get

  • require 'opal_patches' — additive patches for Opal corelib vs real-world gems (Rack, etc.).
  • require 'cloudflare_workers' — Rack handler, Cloudflare bindings, multipart, queue, Durable Objects, etc.
  • runtime/worker_module.mjs — fetch / scheduled / queue / DO adapters (no Opal bundle import).
  • runtime/worker.mjs — thin bootstrap (crypto shim → bundle → worker_module) for legacy layouts.
  • runtime/setup-node-crypto.mjsnode:crypto on globalThis before the Opal bundle loads.
  • bin/cloudflare-workers-build — single build pipeline (ERB → assets → Opal → patch → worker.entrypoint.mjs). Use --standalone in generated apps; it now restores cf-runtime/ automatically and derives standalone template/asset namespaces from the project name by default.
  • docs/ARCHITECTURE.md — wrangler main, codegen entrypoint, and fixed-import policy.

Quick start (homura monorepo)

  1. Gemfile: gem 'homura-runtime', path: 'gems/homura-runtime' and gem 'opal-homura', '= 1.8.3.rc1', require: 'opal' (path or exact pin).
  2. bundle exec cloudflare-workers-build — writes build/hello.no-exit.mjs and build/worker.entrypoint.mjs.
  3. wrangler.toml: main = "build/worker.entrypoint.mjs", compatibility_flags = ["nodejs_compat"].

Support matrix (indicative)

Component Verified (dev)
Ruby 3.4.x
Node ≥ 20
Wrangler ^3.99
Opal = 1.8.3.rc1

Wrangler config

  • Supported as generated / documented: wrangler.toml only.
  • wrangler.json / wrangler.jsonc: manual conversion only; not generated by this toolchain.

License

MIT. See the repository LICENSE.