hotwired-laravel / turbo-laravel

This package gives you a set of conventions to make the most out of Hotwire in Laravel.
https://turbo-laravel.com
MIT License
790 stars 48 forks source link

Investigate Compatibility with Livewire v3 #118

Open tonysm opened 10 months ago

tonysm commented 10 months ago

I'm not sure how well (or if at all) Turbo works with the new version of Livewire. Need to give it a try.

alxndrmlr commented 10 months ago

https://livewire.laravel.com/docs/upgrading#accessing-alpine-via-js-bundle

I haven't done this yet but it seems like the livewire-turbolinks.js code will need to be loaded differently

image

Looks like we'll need to disable the Auto-inject Frontend Assets so we can manually bundle livewire and then hook into it.

tonysm commented 9 months ago

As part of the https://github.com/hotwired-laravel/turbo-laravel/pull/128 PR I removed the Livewire docs page. I'll re-add it once I review the integration (before tagging v2).

99linesofcode commented 6 months ago

Are the two meant to be compatible? I thought these were, not necessarily competing tools, but non the less slightly different approaches and tool chains to achieve somewhat similar results. Is there something more to combining both that I'm not seeing here or is this simply a use case you'd also like to support?

tonysm commented 6 months ago

It used to work well together. There was a bridge JavaScript tool like https://github.com/livewire/turbolinks, but Livewire seems to have opted out of that in favor of its own SPA mode, which is understandable and sad.

I see Livewire as one step towards the progressive enhancement spectrum next to JavaScript. Another aspect is around application scaffolding. Laravel offers Breeze and Jetstream, both of which have Livewire flavors. If Livewire worked well with Turbo.js (again, it used to), we could rely on those scaffolding options and help increase adoption in the Laravel ecosystem. Unfortunately, that's not the case anymore. That's why I started working on Hotstream (which is a Jetstream-like scaffolding but for Hotwire, but I've abandoned the idea as it seems too much and too serious for a single person to maintain - which is not a problem for Jestream, for instance) and Turbo Breeze, which is my current focus right now. I want to offer Breeze-like web scaffolding but also Turbo Native examples with it.

Since Livewire uses MutationObserver now, I thought it would "just work", but that's not the case. I've tested them together briefly, and it no longer works.

Anyway, I don't have time to chase this integration, and it doesn't seem to be desired on the Livewire front anymore (again, it makes sense for them), so I'm inclined to just say they don't work together anymore and move on.

99linesofcode commented 6 months ago

Sad indeed. I've only just worked through setting up my first application with Laravel Turbo so this could be a total shot in the dark but from what I've gathered so far LiveWire seems to focus more on that tight integration with Laravel and the PHP side of the equation. That's perfectly fine but I feel like it's a missed opportunity to standardize things and establish a new paradigm that spans multiple programming languages. Specifically the frameworks like Laravel, Rails and Django that are so very much alike. Would've been nice to see the effort being poured into LiveWire flow towards that goal.

I commend your efforts for trying to stay closer to the original idea/premise and would like to thank you for your work so far. Setup was pretty smooth and I look forward to better understand how everything fits together.

alxndrmlr commented 6 months ago

For what its worth my company Civia.com will continue to pursue finding a solution to make Livewire work with Turbo Native (or something like it whether its a very that doesn't provide all the transitions and stuff that Turbo does).

Mainly because we believe we will want to stay pure HTML over the wire and just have a very simple iOS and Android app that basically just gives us the mobile optimized view but gives us the ability to start handling push notifications. At least to start as we love the idea of building the UI once (to keep our team/costs smaller) until we get to a scale that having a separate pure native iOS and Android app makes sense for us.

It'll be on my back burner for a while as we're mainly focused on building out the platform on web first.