Why I went looking
I wanted one thing from my Rails frontend setup: change a file and see it on the page, without losing where I was.
esbuild through jsbundling-rails gets close. Builds are fast and the config is one line. But every change is a full page reload. The modal I opened, the form I half filled, the Stimulus controller's state: gone, every time. Over a day of UI work that adds up to hundreds of small resets.
Webpacker and Shakapacker give you hot module replacement, but I remember what came with it. A config you are scared to touch, cold builds measured in tens of seconds, and upgrades that meant diffing generated files by hand.
Rspack promised both: webpack's features, including HMR, with a Rust core that builds at esbuild speed. So I tried it on a Rails app, and then I wrapped what I learned into a gem, rspack_rails.
The first ten minutes
A new app is three commands:
rails new myapp -m https://raw.githubusercontent.com/tungnt1203/rspack_rails/main/template.rb
cd myapp
bin/dev
The template asks which extras you want: Stimulus, TypeScript, React, Tailwind CSS, Sass. bin/dev starts Rails and rspack serve side by side.
Then the part that sold me. I edited a Stimulus controller, and the page did not reload. The controller was swapped in place, and the element I was poking at kept its state. Same with CSS, and with React components through Fast Refresh. When I edited an ERB view, the page reloaded on its own, which is what you want for server-rendered HTML.
The layout needs only two helpers:
<%= rspack_javascript_tag "application", "data-turbo-track": "reload" %>
<%= rspack_stylesheet_tag "application" %>
An existing app is bundle add rspack_rails and bin/rails rspack:install. An app on importmap-rails or jsbundling-rails can run bin/rails rspack:migrate from a clean git tree and review the diff.
The numbers
Rspack is not the fastest at everything, and I think that is the honest headline. esbuild still wins a cold build, by a few hundred milliseconds. Rspack wins the number you feel all day: the rebuild after you save a file.
Measured on an Apple M1, Node 26. Medians of 5 cold builds and 10 watch rebuilds, November 2026.
A rebuild after editing one component took 83 ms with Rspack and 279 ms with esbuild, on 1,000 components. Cold development builds were a tie between the two (0.55 s and 0.54 s), with webpack at 1.46 s. Against webpack, Rspack's production build is 6 to 9 times faster.
And the rebuild number undersells it. esbuild has no HMR, so after its rebuild the browser still reloads the whole page. Rspack sends only the changed module.
How I measured: the same generated React 19 + TypeScript app (lodash-es, date-fns), built to ES2022 with source maps. esbuild runs with the flags jsbundling-rails uses, plus --minify. webpack 5 uses swc-loader, as Shakapacker can. Times include about 0.2 s of npx and Node startup. Gzipped output was 100 KB for Rspack and webpack, 120 KB for esbuild.
The proxy rspack_rails puts in front of the dev server costs about 1.8 ms per page navigation.
What I learned building the gem
Getting Rspack to run in Rails takes an afternoon. Getting it to stay out of your way took the rest. Four decisions mattered most.
Production stays boring. Rspack writes to app/assets/builds, and Propshaft or Sprockets fingerprints and serves the files, the same way jsbundling-rails works. Production never needs Node at runtime, and there is no second manifest system to debug at 2 a.m.
The dev server hides behind Rails. Pages load scripts from /rspack/... on the app's own origin, and Rails proxies them to rspack serve. I learned why the hard way: browsers refuse to start a Web Worker from another origin, so loading straight from localhost:3036 breaks workers. Only the HMR websocket talks to the dev server directly.
The config is owned, not generated once. Webpacker's pain was a config generated on install and never upgraded again. Here the base config, config/rspack/rails.mjs, belongs to the gem and is rewritten on every upgrade. Your changes live in a callback in rspack.config.mjs. If someone edits the gem's file by hand, a checksum notices and the edit is backed up before anything is replaced.
A doctor that tells you what to type. bin/rails rspack:doctor checks Node.js, packages, config, layouts, Procfile.dev, the Dockerfile and the dev server. Every warning ends with the command that fixes it. It is the first thing I run when something looks off.
The bugs that taught me the most came from real apps, not tests. Migrating an app with two layouts showed that the admin layout silently lost its JavaScript. That fix shipped in 1.0.0.rc2.
When you should not use it
If your app has a few Stimulus controllers and no npm packages that need bundling, stay on importmap-rails. It is the Rails default for good reasons: no Node, no build step, nothing to learn.
If you bundle but never miss HMR, esbuild through jsbundling-rails is a fine choice. It is simple, very fast on cold builds, and has fewer moving parts than any webpack-style tool.
rspack_rails is for the point where you want more than that: React or TypeScript with Fast Refresh, code splitting, CSS modules, loaders, or the webpack plugin you already know. That is where I kept wishing for webpack's features without webpack's wait.
Try it
rspack_rails 1.0 is on RubyGems. It supports Rails 7.2 and 8.x, Propshaft and Sprockets, and npm, Yarn, pnpm and bun.
rails new myapp -m https://raw.githubusercontent.com/tungnt1203/rspack_rails/main/template.rb
- Code and docs: github.com/tungnt1203/rspack_rails
- Demo app: rspack_rails-demo
If you try it on a real app, I would love to hear what broke. The best fixes so far came from exactly that. Open an issue, or tell me in the comments.

Top comments (0)