mampf icon indicating copy to clipboard operation
mampf copied to clipboard

Webpacker has been retired / Upgrade frontend bundling

Open Splines opened this issue 1 year ago • 6 comments

From the Webpacker Readme:

Webpacker has served the Rails community for over five years as a bridge to compiled and bundled JavaScript. This bridge is no longer needed for most people in most situations following the release of Rails 7. We now have three great default answers to JavaScript in 2021+, and thus we will no longer be evolving Webpacker in an official Rails capacity.

Finally, you can continue to use Webpacker as-is. We will continue to address security issues on the Ruby side of the gem according to the normal maintenance schedule of Rails. But we will not be updating the gem to include newer versions of the JavaScript libraries. This pertains to the v5 edition of this gem that was included by default with previous versions of Rails.

So, while we can except some more security updates in the short term, we should definitely adopt one of Rails 7 "new answers to JavaScript" in the long run, to still get security updates (in the distant future) and also new JS features.

So that's the story for JavaScript in Rails 7 and beyond. A default path with Hotwire and import maps, an alternate path using a thin integration with one of the popular JavaScript bundlers. [...]

A quote on the old Asset Pipeline (Sprockets) vs. new approaches

"The problem with Sprockets (the old assets pipeline) is that it did not integrate with front-end package distribution systems like NPM or Yarn and relied on the community to make gemified versions of these packages. If you wanted to use something that was not available as a gem you would have to download it manually or integrate Webpack or some other package manager anyways. It was pretty great back when rails was one of the only frameworks to ship with an assets pipeline but is completely obsolete today." ~ from here

Further resources

Splines avatar Apr 11 '23 14:04 Splines