This content originally appeared on DEV Community and was authored by Shayan Holakouee
Over the last few weeks, DHH and the Rails core team have announced a number of different JavaScript build tools for use with Rails 7. As I was writing this very post, DHH wrote his own post outlining the strategy for Rails 7 and JavaScript. There is no doubt that Ruby on Rails fans were eagerly awaiting the release of Rails 7, and its numerous new features and updates. One of the most notable new features included in Rails 7 is Hotwire; modern and dynamic web applications can be built using this approach without having to write any JavaScript.
Rails 7 offers different of ways to interact client-side code from a Rails app:
The classic asset pipeline route via Sprockets and manifest files still will work as far as I can tell, but I think you might want to look at a newer tool.
Webpacker is still under active development, and should release a new version more or less simultaneously with Rails 7. I definitely take from DHH’s post, though, that Webpacker is soft-deprecated in favor of the JS Bundling approach.
Rails 7 will support “JavaScript Bundling” as of literally 10 minutes ago as I started this post. The JavaScript bundling tool uses the existing Yarn and package.
json tooling, but places the bundle into the asset pipeline. For you your bundling took you can use Webpack, esbuild, a webpack replacement that bills itself as “An extremely fast JavaScript bundler”, which I suppose is better than a merely fast one, or a slow one, or Rollup.
Rollup doesn’t have a fancy marketing slogan, but it’s also a JavaScript module bundler.
The default Rails 7 tooling is called “import maps", which is a browser tool that lets you map a logical name to a downloaded module directly in the browser without needing to do further bundling on the server for the browser, and a Rails wrapper to manage that mapping from your codes.
Finally, you can just use Rails as an API, and manage your client side code as a separate project using whatever tooling you want.
Hotwire, one of the most talked-about features of Rails 7, is without a doubt the greatest feature of the new release since it has gained attention both in the Rails community and in those of other programming languages
This content originally appeared on DEV Community and was authored by Shayan Holakouee
Shayan Holakouee | Sciencx (2021-12-16T17:08:30+00:00) Rails 7, The Shinning Star We’ve been waiting for. Retrieved from https://www.scien.cx/2021/12/16/rails-7-the-shinning-star-weve-been-waiting-for/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.