What is the state of this guide? The merge request does not cover many of the points above. I think it is a really good idea, since there is a lot of confusion on this topic.
It pretty much comes down to the block below. If you want more details on why, I gave a talk about this topic at RailsWorld and that should probably be available soon at the official youtube channel.
I would add that it also seems to become possible to do JavaScript bundling without node/yarn by using bun instead?
I actually have to update that, as itās more about āno-buildā or āall the buildsā, instead of node specifically.
I no longer have permission to edit my original post, so Iāll post this here. Itās my Rails World talk where I explain how to old asset pipeline worked, how the new one works, and why you should be using the gems in my TL:DR.
Hey, thanks for the guide! It did indeed cleared a few things.
Iād like to ask for help to clarify one question thoughā¦
Weāve recently upgraded an old rails app from Rails 5 to Rails 7, skipping Rails 6 step completely (mainly because of webpacker). Upgrading Sprockets from 3 to 4 required way more effort than we initially anticipated, so weāve stayed with Sprockets v3 - because, hey, it just works. Donāt fix whatās not broken, you knowā¦
Weāre also using Coffeescript, if that matters.
Now weād like to introduce Turbo to this app.
There are plenty of guides on how to make Turbo work with webpack, with importmaps, with jsbundling, and whatnotā¦ but none regarding Sprockets 3. Soooā¦ is it possible at all? Without adding any transpliers, builders, or other things like esbuild & node shtuff, if thatās possible, of course.
On a side note, Stimulus install guide says that it can be used without a build system at all. Does Turbo support this approach as well (using the gem to add server side bits and bobbles, and adding some plain js to layout so the browser takes care of the rest)?
Iāve stopped using Sprockets for JS years ago, so I canāt help much with that.
That said, yes, Turbo can be used without a build system. DHH is curently dedicating himself to ensuring that all parts of the Rails JS libraries works perfectly without a build system at all.
Ah, thatās some good news, thank you!
Iāve managed to get Turbo to work with Sprockets 3.
After bundling the turbo-rails gem, adding this to the <html><head>
did the trick:
<%= javascript_include_tag "turbo", type: "module" %>
<script type="module">
import {Turbo, cable} from "<%= asset_path("turbo") %>"
Turbo.session.drive = false
</script>
(I prefer to start with Turbo disabled by default, and then enable it step by step)
Thank you for your help.
That would be me, thanks!