-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
This issue comes from a meeting @coorasse, @spaghetticode and I had to discuss the feasibility of supporting Webpacker into Solidus. These are the notes of the meeting. We want to use them to start a conversation and taste the general feelings around this.
Webpacker is the default JavaScript compiler in Rails 6.
Right now we totally rely on Sprockets for JavaScript compilation. Do we want to make any effort to support Webpacker as well? Of cource it would be optional, so we don't break existing store and leave users the possibility to chose what they prefer to use.
We'd still need Sprockets
From https://github.com/rails/webpacker:
It coexists with the asset pipeline, as the primary purpose for webpack is app-like JavaScript, not images, CSS, or even JavaScript Sprinkles (that all continues to live in app/assets).
It's the JavaScript compiler, not images, CSS, fonts one. We'd still need Sprockets for the other things.
There's still no any Rails way
Although some solution is started to be presented, in this issue on Webpacker there is still a lot of confusion, and there's no a clear path on how to use Webpacker in combination with JavaScript files served by a Rails engine.
Also, this guide has been published but it's not super clear how it would work with Solidus (and its extensions).
Backend
We think that since we would still need Sprockets for other assets, there could not be a lot of value supporting support Webpacker here.
If we want, we could start preparing things by removing all js.erb files that would be an issue with Webpacker, and generally, are probably not a good practice. Still not sure how it works with js views.
Frontend
Solidus frontend is meant to be replaced.
That said, every store can already easily install Webpacker on their frontends and take care of the rest without too much constraint from Solidus.
Extensions
Given for granted that we are ok leaving Sprockets on the backend, we'll only talk about frontend related stuff here.
This is complicated. We have extensions that inject JavaScript code into the frontend application.js manifest. This is done in the extensions' install script.
If Webpacker is being used on the frontend this is useless, if not dangerous. We should find a way to don't copy those files if Webpacker is used.
An initial idea could be adding a Spree::Config.webpacker.frontend_enabled? in solidus_core that let us understand from the extension if Webpacker is being used and if we need to append the require in the manifest.
At that point, JavaScript files should be manually copied into the application frontend and being included into the Webpacker folder structure. This is far from an ideal solution but we can't see any other way to work around this.
Everyone feedback welcome!
This issue can't go ahead without the community. Do someone else have experience or thoughts about this?