DEV Community

Alex Aslam
Alex Aslam

Posted on

3

Rails 8’s JavaScript: Goodbye Node, Hello Ruby?

"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 utilitiesrails-ujs reborn

# Gemfile
gem "importmap-rails" # No Node required
gem "turbo-rails"     # Ships with Rails 8
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

After (Rails 8):

bin/importmap pin react
# That’s it. No Node.
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

5. The New Rails Frontend Stack

  1. HTML-first – Turbo Frames/Streams
  2. Progressively enhanced – Stimulus 3.0
  3. Ruby-managed JS – Import Maps + esm.sh
  4. 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]
Enter fullscreen mode Exit fullscreen mode

6. Migration Tips

  1. Start fresh: rails new my-app --skip-javascript
  2. Pin dependencies:
   bin/importmap pin react-dom @hotwired/turbo-rails
Enter fullscreen mode Exit fullscreen mode
  1. Audit app/javascript: Move to app/assets/javascript

“But Our Team Loves React!”
Try this:

  1. Keep React for one route (via Bun)
  2. Use Turbo for the rest
  3. Compare dev experience

Tried Rails 8’s new JS setup? Share your wins/fails below!

Warp.dev image

The best coding agent. Backed by benchmarks.

Warp outperforms every other coding agent on the market, and gives you full control over which model you use. Get started now for free, or upgrade and unlock 2.5x AI credits on Warp's paid plans.

Download Warp

Top comments (2)

Collapse
 
xwero profile image
david duymelinck • Edited

Import maps aren't that difficult. So you don't really need a gem.

It is a great feature in my book. With the bundlers you didn't have a good view on what gets loaded.

Collapse
 
alex_aslam profile image
Alex Aslam

Great point! Import maps are indeed simple and powerful, we love how they bring transparency to dependency loading. The gem just adds Rails conveniences like dependency pinning and SRI hashes, but you're absolutely right: the native browser feature alone is game-changing.
"The best tools stay out of your way while making the right thing easy."
Would love to hear how you're using import maps in your projects!

Runner H image

Automate Your Workflow in Slack, Gmail, Notion & more

Runner H connects to your favorite tools and handles repetitive tasks for you. Save hours daily. Try it free while it’s in beta.

Try for Free

👋 Kindness is contagious

Take a moment to explore this thoughtful article, beloved by the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A heartfelt "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay