Shakapacker 7

railsAugust 30, 2023Dotby Mostafa Ahangarha

Shakapacker, the official successor of Webpacker, is the Ruby gem that brings the full power of webpack into the Ruby on Rails world. Unfortunately, we could not keep the old gem name. We kept the old name internally but with a new gem name to expedite the transition. Thus, some docs and code mentioned webpacker, and some mentioned shakapacker. Ughhh.

Shakapacker 7 is now fully Shakapacker. Let’s look at this release and discuss if you should consider an upgrade.

Background

Rails maintainers released official Webpacker versions up to 5.4.3. Despite several release candidates, version 6 was never officially released. The Rails core team decided to migrate away from the Webpacker project in favor of simpler bundling solutions, including jsbundling-rails and importmap-rails. However, those solutions work poorly for JavaScript-heavy frontends like React or Vue.

Justin Gordon and the ShakaCode team offered to adopt Webpacker, and the Rails maintainers accepted the offer. David Heinemeier Hansson gets credit for the Shakapacker name!

Shakacode drove the unreleased Webpacker 6 code to an official release, Shakapacker 6. ShakaCode did only the minimal gem renaming to simplify adoption for those upgrading. For example, after adding the Shakapacker gem to a project, one needed to run rails webpacker:install; to run webpack dev-server, one needed to run bin/webpacker-dev-server; the configuration was stored in config/webpacker.yml; and many more.

Finally, it is entirely Shakapacker

Now, Shakapacker is fully Shakapacker. Version 7 has replaced any instance of Webpacker In the entire project with Shakapacker (including in file names, configurations, environment variables, rake tasks, etc.). For example, after adding Shakapacker to a project, one needs to run rails shakapacker:install; configurations are stored in config/shakapacker.yml; and so on.

Additionally, we worked carefully to keep these changes backward compatible. After upgrading to version 7, your project should still work as before, except you get several deprecation messages in the terminal. The warning messages should be clear enough to help you apply the changes in the right place.

We worked hard to ensure backward compatibility in this regard, but the possibility of a break exists depending on the project implementation. While the upgrade process for this change is seamless (documented in the v7 upgrade guideline), we appreciate a detailed report for any possible break. Ensure to check out the changelog and the upgrade guideline for other changes.

Should I upgrade?

Definitely! Upgrading to Shakapaker 7 means benefiting from new features, higher performance, and better support.

With our attempts to make the process easy, straightforward, and seamless, nobody should feel overwhelmed by this upgrade. Follow the v7 upgrade instructions. Your changes should be minimal to get your app running on v7. Then make the changes required to remove the deprecation warnings.

Besides this general advice, projects such as react-rails and react_on_rails have started to support Shakapacker 7. Regarding ReactRails v3, Shakapacker 7 is the only supported solution alongside Sprockets.

If you still have a project using Webpacker and would like help with upgrading, please contact Justin Gordon, [email protected]. With ShakaCode's help, your team can stay focused on features and bug fixes tech debt rather than getting bogged down in upgrading frontend dependencies and toolchains.

Closing Remark

Could your team use some help with topics like this and others covered by ShakaCode's blog and open source? We specialize in optimizing Rails applications, especially those with advanced JavaScript frontends, like React. We can also help you optimize your CI processes with lower costs and faster, more reliable tests. Scraping web data and lowering infrastructure costs are two other areas of specialization. Feel free to reach out to ShakaCode's CEO, Justin Gordon, at [email protected] or schedule an appointment to discuss how ShakaCode can help your project!
Are you looking for a software development partner who can
develop modern, high-performance web apps and sites?
See what we've doneArrow right