Importmap setup for Stimulus controllers (Rails 7 style)

1427
0

If you’re using importmap, a clean Stimulus setup matters: it keeps controllers discoverable and avoids mystery load order bugs. I pin @hotwired/turbo-rails and @hotwired/stimulus, then use controllers index discovery to register everything. The payoff is that you can add a new controller file and it “just works” without editing a bundler entrypoint. In teams, this keeps the frontend footprint small and aligns with Hotwire’s philosophy: most UI is HTML; JS exists to enhance. I also like to keep controller names consistent (thing_controller.js) and avoid nested folders unless there’s a clear domain boundary.