"We ditched Node, Webpack, and 12,000 files from node_modules—here’s why you should too."
For over a decade, Rails developers begrudgingly accepted JavaScript tooling chaos as the price of modern frontends. But with Rails 8’s upcoming release and Bun’s meteoric rise, we’re witnessing something radical: a return to simplicity without sacrifice.
After rebuilding a production app with Rails 8 (alpha) + Bun, we discovered a stack so fast and clean, it feels like Rails 3.0 excitement all over again. Here’s what’s changing—and when to make the jump.
1. Why This Combo Changes Everything
The Speed Revolution
Task | Rails 7 (Webpack) | Rails 8 (Bun) |
---|---|---|
bundle install |
28s | 28s |
javascript:install |
42s | 0.9s |
assets:precompile |
1.2min | 8.4s |
Dev Server HMR | 2.3s | 0.3s |
# The magic command
rails javascript:install:bun
What You Gain
✅ No more node_modules
(Bun uses a single cache)
✅ Zero-config JSX, TypeScript, and Sass
✅ Built-in WebSocket server for Hotwire
2. Rails 8’s Secret Sauce
1. Import Maps Meet Bun
# config/importmap.rb
pin "react", to: "https://esm.sh/react@18"
pin "application", preload: true
How it works:
- Development: Uses ESM directly (zero build)
- Production: Bun optimizes into lean bundles
2. The New javascript:build
Hook
# Automatically runs during assets:precompile
Rails.application.config.javascript.build_command = "bun build"
Killer feature:
- No more fighting Webpack in CI
- Cache-friendly output
3. Unified Errors
Bun + Rails backtrace:
app/javascript/controllers/index.js (Line 12)
app/models/user.rb (Line 8)
Finally: JS and Ruby errors in one trace.
3. Real-World Migration
Case 1: Converting a Webpacker App
- Delete:
rm -rf node_modules package.json webpack.config.js
- Install:
bundle add jsbundling-rails
rails javascript:install:bun
- Celebrate 18,000 fewer files.
Case 2: Hybrid Architecture
// Use Bun for React components
import Chart from "./react/Chart"
// Keep Stimulus for progressive enhancement
application.register("chart", ChartController)
Best of both worlds:
- Complex screens: React + Bun
- Traditional views: Turbo + Import Maps
4. When to Think Twice
❌ Legacy apps with jQuery plugins
❌ Teams married to npm/yarn workflows
❌ Projects needing WebAssembly builds
Golden Rule:
Use this stack when you want modern JS without the tooling circus.
5. Getting Started Today
- Install Bun:
curl -fsSL https://bun.sh/install | bash
- Try Rails 8 alpha:
gem install rails --pre
rails new my-app -j bun
- Convert existing apps:
bundle add jsbundling-rails
rails javascript:install:bun
“But We Just Migrated to Vite!”
Try this:
- Keep Vite for one complex route
- Use Bun everywhere else
- Compare dev experience
Made the switch? Share your war stories below!