react_on_rails
react_on_rails copied to clipboard
Decouple from Webpacker and support jsbundling-rails, importmaps-rails
Rails is leading towards multiple JavaScript bundlers support with jsbundling-rails, which will be shipped with Rails 7 (it is already available on Rails 7 alpha).
There is even importmap-rails, which fits with React less than jsbundling-rails as JSX requires a JS bundler, but since React can be used without JSX it could be sensible to support it too.
@mdesantis I'm totally open to a PR. Would SSR still work with importmap-rails?
@justin808 that's a good point, I didn't think about that. Import maps is a client-side only feature, but I guess that technically you could use CLI JS bundling for the SSR part and import maps bundling for the hydration part. But it would be weird I guess: once you have CLI JS bundling set up I can't see any reason to use a different bundling logic client side.
@mdesantis can you hack around with this. Ping me if you need help. https://join.slack.com/t/reactrails/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE
@justin808 I'd really love to, but my free time is really short nowadays, you know, family and such. But I'll do all the best to find some time to dedicate to this, it's appealing to me. Thank you for suggesting using React plus Rails Slack, I'm already there, I'll surely use it if needed.
@mdesantis have you had a chance to look into this?
No I'm sorry, I have other priorities right now :-/
I'd love for the gem to support jsbundling-rails. I actually came to the repo hoping to find that it was supported. Thanks for starting the conversation!
I'd love to see some sort of POC of that. And what would be the advantage, compare/contrast to using rails/webpacker?
it would be great to make a PR of this repo showing using jsbundling-rails. And what about css?
https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/
I would also like to see a POC of getting it to work.
The advantage of using js-bundling, in my opinion, is that you are not relying on a dead technology. Rails is using js-bundling now, rather than webpacker. DHH has made it pretty clear that he never liked the webpack path and he is happy to be off of it. Based on that, I don't expect to see many new versions of webpacker. I could be wrong though, and the community could keep webpacker going.
I don't actually have an answer about css as I don't use webpack for css.
I realize there is a level of complexity added because js-bundling supports many different build tools, but I'm sure it is possible to get react on rails running on it.
Thanks for taking the time to respond to me 🧡
@brandoncc React on Rails previously did not depend on webpacker. If you see changes I made to React on Rails where I required webpacker, you'd have an idea of what can be done.
Do you have time to help me work on this?
Here's a Slack invite.
@brandoncc Please see https://discuss.rubyonrails.org/t/shipping-webpacker-v6-status/79683 and let me know your thoughts.
Thanks for pointing me to that thread. The last thread I saw about webpacker v6 was also on discuss.rubyonrails.org and was about how v6 was seemingly never coming out.
If you are taking on maintainership of webpacker, that cancels my argument about relying on a dying technology. That is a good thing. I do think more and more people will start their apps with js-bundling, and may not be willing to go to webpacker since js-bundling can also handle webpack integrations.
In my opinion, it would be ideal if js-bundling was supported, even if it was only the webpack flavor of js-bundling that was supported.
I'll join the slack and see what we can do to make this happen together.
Here is a summary of where this stands.
- There isn't any technical reason why js-bundling can't be supported (I'm not sure about importmaps, but the same may be true for that).
- There isn't a dummy app showing how to make this work, so it is assumed not to work. That can be remedied once the actual integration path is figured out and tested by someone (could be me, or someone else).
- There is a small portion of the code that depends on webpacker, but it can be worked around fairly easily
- We don't actually care what bundles the code, only that it does get bundled.
Justin has been working toward a webpacker 6.0 release, and is looking for feedback on the milestones. If you would like to see any of them happen, please drop a 👍 on them.
Closing for now. I don't see a strong reason to support js-bundling over shakapacker.