Open dacook opened 1 year ago
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:
From the article, there are three alternatives:
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.
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
.
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.
How about using shakapaker? @openfoodfoundation/developers
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.
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