hotwired / turbo-rails

Use Turbo in your Ruby on Rails app

Home Page:https://turbo.hotwired.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible install instruction change needed for Webpacker 6

noelrappin opened this issue · comments

I was trying to run the install instructions against the Webpacker 6 beta.

Taking my example which already worked against Webpacker 5, and upgrading Webpacker, my Turbo install was no longer downloading. (The links that had been identified in the log as being processed as TURBO_STREAM no longer were, the behavior was no longer working, and Turbo was no longer in the sources tab).

Adding a console.log(Turbo) to the application.js file makes everything work again, so I guess I'd assume that the switch to Webpacker 6 and the javascript_packs_with_chunks_tag helper somehow doesn't realize that Turbo is being used and therefore doesn't download it with the pack?

Is there a preferred way of managing this?

Thanks!

Sounds like Webpack is shaking its tree and not finding any usages of Turbo in the pack itself. @javan any idea how we might stop this from happening? Maybe with Webpack we shouldn't have the lib call start() itself.

I'm experiencing the same with webpacker 5.1.1. To get around it I've added a Turbo.start() call after the import, as it looks like this should have no effect beyond persuading Webpack to keep Turbo in the tree.

I'm only using javascript_pack_tag, not javascript_packs_with_chunks_tag.

Does this "fix" it?

- import { Turbo, cable } from "@hotwired/turbo-rails"
+ import "@hotwired/turbo-rails"

Does this "fix" it?

- import { Turbo, cable } from "@hotwired/turbo-rails"
+ import "@hotwired/turbo-rails"

Yes, this works fine.

Yeah that worked for me under Webpacker 6 beta also.

Thanks, same for vite

For Turbo itself, this was not necessary, but ActionCable only worked in this way.