This content originally appeared on DEV Community and was authored by Alex Aslam
“We deleted our node_modules
folder—and nothing broke.”
For over a decade, Rails developers begrudgingly accepted Node.js as a necessary evil. But with Rails 8’s upcoming changes, the JavaScript landscape is shifting dramatically—back toward Ruby.
After testing the latest alpha, we discovered a surprising truth: You can now build modern frontends in Rails without touching npm
, yarn
, or even a bundler. Here’s what’s changing, why it matters, and when you should (and shouldn’t) jump in.
1. The Rails 8 JavaScript Revolution
What’s New?
Import Maps by default – No more Webpacker
Bun support out of the box – For when you do need a build step
Stimulus 3.0+ Hotwire Turbo 8 – Morphing DOM updates
Ruby-driven JS utilities –
rails-ujs
reborn
# Gemfile
gem "importmap-rails" # No Node required
gem "turbo-rails" # Ships with Rails 8
2. Bye-Bye Node, Hello Ruby
The Death of package.json
Before (Rails 7):
node -v # 18.16.0
yarn install # 142 packages
webpack-dev-server # 4.2s startup
After (Rails 8):
bin/importmap pin react
# That’s it. No Node.
How?
- CDN-based dependencies via
esm.sh
/skypack
- Zero local JavaScript toolchain
3. Real-World Impact
Case 1: Faster CI Pipelines
Step | Rails 7 (Webpack) | Rails 8 (Import Maps) |
---|---|---|
Install deps | 48s | 0s |
Build assets | 22s | 0s |
Total deploy time | 3.1min | 1.4min |
Case 2: No More Node Conflicts
# No more:
ERROR: Node.js 18.17.1 is required (you’re using 16.20.2)
4. When You Still Need Node
React/Vue SPAs (Use Bun instead)
Legacy Webpacker apps (Migration required)
npm-only packages (e.g., specialized charting libs)
Hybrid Approach:
# Gemfile
gem "bun-rails" # Opt-in Bun bundling for specific packs
5. The New Rails Frontend Stack
- HTML-first – Turbo Frames/Streams
- Progressively enhanced – Stimulus 3.0
-
Ruby-managed JS – Import Maps +
esm.sh
- Opt-in bundling – Bun for heavy components
graph TD
A[Turbo] --> B[Zero-Build HTML]
C[Stimulus] --> D[Lightweight JS]
E[Bun] -->|Only when needed| F[Optimized Bundles]
6. Migration Tips
-
Start fresh:
rails new my-app --skip-javascript
- Pin dependencies:
bin/importmap pin react-dom @hotwired/turbo-rails
-
Audit
app/javascript
: Move toapp/assets/javascript
“But Our Team Loves React!”
Try this:
- Keep React for one route (via Bun)
- Use Turbo for the rest
- Compare dev experience
Tried Rails 8’s new JS setup? Share your wins/fails below!
This content originally appeared on DEV Community and was authored by Alex Aslam