Import maps are a web standard that lets browsers resolve bare module specifiers like `import { Controller } from "@hotwired/stimulus"` without a build step. The importmap-rails gem generates the importmap script tag via `javascript_importmap_tags`, reading from `config/importmap.rb`. The `pin` directive maps individual packages (downloaded via JSPM or other CDNs into vendor/javascript), while `pin_all_from` maps entire directories under a namespace prefix. This enables patterns like auto-registering Stimulus controllers via `eagerLoadControllersFrom` and custom Turbo Stream actions, all without bundlers like esbuild or Vite.

5m read timeFrom railsdesigner.com
Post cover image
Table of contents
Import maps, just a web standardConfiguring with pinMapping directories with pin_all_fromExample: custom Turbo Stream actionsHow Stimulus controllers use this

Sort: