Ditch Node.js: A Simple Guide to Rails Importmaps
How Importmaps Work in Rails (And Why You Don't Need Webpack) When I first started building modern Rails apps, managing JavaScript was always the most annoying part. We had Webpacker, package.json,...

Source: DEV Community
How Importmaps Work in Rails (And Why You Don't Need Webpack) When I first started building modern Rails apps, managing JavaScript was always the most annoying part. We had Webpacker, package.json, and massive node_modules folders that took up gigabytes of space on my computer. Very often I found myself tired of waiting for Webpack to compile my code just to see a small JavaScript change in the browser. It felt very heavy, especially for solo developers. Then Rails introduced Importmaps. At first, I was very confused. How could I use libraries like Lodash, Chart.js, or Stimulus without running npm install? Once I understood how it actually works under the hood, I realized it is a genius solution. Here is a simple explanation of how Importmaps work in Rails and how to use them. The Core Concept: A Dictionary for the Browser Modern web browsers are actually very smart now. They natively understand ES Modules. This means if you write import canvasConfetti from 'canvas-confetti', modern Ch