Article originally published here : https://alsohelp.com/blog/rollup-vs-esbuild-for-rails
Rollup and esbuild are two ways to produce an production-optimized JavaScript file, thanks to jsbundling-rails.
ESBuild vs Rollup locally
You can create a new Rails application, with rollup for handling JS assets, with
rails new myapp --database = postgresql -j = rollup -c = tailwind
Enter fullscreen mode
Exit fullscreen mode
postgresql is necessary if you want to try the final result in production.
For esbuild, try
rails new myapp --database = postgresql -j = esbuild -c = tailwind
Enter fullscreen mode
Exit fullscreen mode
Difference between ESBuild and Rollup locally
Both are very transparent IMHO. I wrote several articles about the best way to handle JS with Rails some years ago, now I have to admit those articles are deprecated.
It's set-and-forget setup, you don't have to care much about how JS files are handled.…