Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace rails/webpacker #10298

Open
dacook opened this issue Jan 19, 2023 · 5 comments · May be fixed by #12188
Open

Replace rails/webpacker #10298

dacook opened this issue Jan 19, 2023 · 5 comments · May be fixed by #12188
Assignees

Comments

@dacook
Copy link
Member

dacook commented Jan 19, 2023

We use the gem rails/webpacker, which has been retired.
Some of its dependencies already have security warnings and can't be automatically updated (eg loader-utils), because webpacker locks to the older versions.

The webpacker readme provides a few suggestions on how to proceed.


Edit: consensus is to try jsbundling-rails

@mkllnk
Copy link
Member

mkllnk commented Jan 31, 2023

We moved all assets into the webpacker directory to manage it there. I reckon that we should revert that one by one and tackle the Javascript part last. We will be reverting a lot of this pull request:

It has 51 commits and many of them deal with individual packages like Foundation and jQuery. It may be useful to have a hybrid system for a while. I picked relevant commits here in reverse order to act on:

@abdellani
Copy link
Member

From the article, there are three alternatives:

  1. importmap-rails the default approach that will be used on Rails 7.
  2. jsbundling-rails

If you're on Webpacker today, it's a very modest jump to switch to one of the bundlers made available through the jsbundling-rails gem. You don't even have to stick with Webpack. Fundamentally, they all work in the same way: take an entry point, produce a build. We've initially taken that path with Basecamp 3, converting from Webpacker to esbuild. But with HEY, we took the full step of going straight to import maps. Neither choice involved a lot of effort. The JavaScript is still the JavaScript. You're mostly adjusting a few import paths.

  1. Separate the backend (Rails API) and the frontend ( I don't think that this is an option for us since we are moving to stimulus)

From what I can see, the first approach will be the best fit when AngularJs will be removed.

In the meantime, while it's still possible to use the first on the presence on AngularJS, I'm not sure if we should use jsbundling-rails.

@mkllnk
Copy link
Member

mkllnk commented Mar 27, 2023

jsbundling-rails seems to be closer to what we do at the moment. So I would start there. We do have JS templates which contain Ruby code. And I believe, but I may be wrong, that importmaps-rails doesn't support this mix.

@dacook dacook linked a pull request Apr 13, 2023 that will close this issue
@abdellani abdellani self-assigned this Dec 22, 2023
@abdellani
Copy link
Member

How about using shakapaker?
@openfoodfoundation/developers

@mkllnk
Copy link
Member

mkllnk commented Jan 2, 2024

How about using shakapaker?

Yes, that would be the easiest path forward for now because it offers backwards-compatibility with webpacker. Long-term, I would like to get closer to the original Rails asset pipeline with sprockets and importmap. Default packages are often better maintained and tested. And Rails usually picks very good defaults which are still quite simple and robust while offering everything you need.

Anyway, if we can't jump straight back to the defaults then we should transition to Shakapacker for now.

@abdellani abdellani linked a pull request Feb 22, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress ⚙
3 participants