META: Incorporate Symfony UX Turbo Into Module

Created on 23 September 2021, about 3 years ago
Updated 21 February 2024, 9 months ago

Postponed

See πŸ“Œ Hotwire Turbo minimum viable implementation Active for more information. We may implement this at a later date but it's out of scope for the time being.

Problem/Motivation

References:

The links above show an overview of what Symfony UX is trying to accomplish as well as the "Hotwire Turbo integration for Symfony" which relates to this project. This issue was created to gauge interest in working to use as much Symfony UX Turbo as possible and see what contributors to this project have to say about the idea.

I believe work in the "ux-turbo" repo can be incorporated into this project, specifically the TurboStreamResponse class and integration into the router component.

Proposed resolution

I'm not far into investigating how this module can be updated to integrate with what Symfony is doing, but I wanted to see if others had feedback as well as have someplace where potential collaboration can be had between Drupal and Symfony communities.

Changes I know so far that have to be made:

  • All JS needs to be loaded in <head> and not the end of <body>. An initial solution might be to move the js-bottom to the placeholder for the head-js.
  • BigPipe - I'm not sure where Drupal is at with BigPipe and if it played out as people wanted. But I imagine the placeholder tags would interfere with registering Stimulus controllers and attaching them to events.
  • Drupal.behaviors "attach" needs to fire on turbo events. There are no page refreshes so looking for a load event won't work. It's more an event like turbo:load that needs to be listened to.
  • Drupal.behaviors would be converted to use Stimulus controllers.
  • TurboStreamResponse has to be implemented in some way for turbo streams to work properly. Hopefully using Symfony components for routing in Drupal helps make this addition easier.
  • Integrate the Entrypoints module or some other way to load bundled CSS/JS. I'm not sure if Webpack Encore will continue or they will move to an unbundled "import map" approach like in Rails 7...but if more Encore features can be utilized then it takes more maintenance burden off of Drupal's contributors.
  • A theme with templates for Turbo needs to be created and linked with this project. Symfony UX uses Twig also, so once again, hopefully, the templating work is made easier by re-using what Symfony is already developing.

That's about all I can think of for now. I really like the idea and experience of Refreshless, and I hope enough people are interested in the Drupal world to provide a coupled, monolithic version of Drupal that still feels like a SPA done with JS...then the people with large budgets and many devs can take the decoupled approach. However, every Drupal project I've worked on (in small teams, mainly) would benefit more from Turbo than Decoupled Drupal.

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

🌱 Plan
Status

Postponed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States afinnarn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Thank you so much for taking the time to do this write-up, @afinnarn, and for refining it, @Ambient.Impact! 🀩 πŸ‘

    Hesitation

    I am hesitant/concerned about adopting https://turbo.hotwired.dev/ because of the big notice you can see at the top of https://www.drupal.org/project/turbolinks β†’

    They were very aggressive about it.

    Then again … https://github.com/symfony/ux-turbo seems to have been around for a while and they somehow did not get shouted at by the creators of Turbolinks? πŸ™ƒπŸ€·

    Technically

    Technically speaking, I'm not at all opposed to reusing a Symfony component! πŸ˜„

    +1 for @Ambient.Impact's proposal to (at least initially) require BigPipe to be disabled.

    Drupal.behaviors would be converted to use Stimulus controllers.

    This sounds like it would be impossible to make it work automatically for contrib/custom modules' Drupal.behaviors? πŸ˜…πŸ˜± Sounds like @Ambient.Impact has similar concerns.
    We'd need to figure out a way to make this work transparently, otherwise this seems not viable. (I did not look into what "Stimulus controllers" are.)

    Similar concerns apply to the loading of additional CSS/JS.

    Conclusion

    Big +1 for creating a new branch of Refreshless that adopts this! But prior to building it all, I think we should prototype the foundations to ensure it can work as early as possible, without spending weeks/months on building this. Happy to provide reviews 😊

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    OMG, it looks like this prototype now already exists!?

  • πŸ‡³πŸ‡±Netherlands sebastian hagens Breda, Netherlands

    @WimLeers

    @Ambient.Impact showed me a video of the prototype through Mastodon a while ago, but I can't find it anymore.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I watched presumably the same video in in a Drupal Slack DM earlier today.

    The next step here is to i) review, ii) manually test πŸ“Œ Hotwire Turbo minimum viable implementation Active . You could help with that, @Sebastian Hagens πŸ˜„

  • πŸ‡¨πŸ‡¦Canada ambient.impact Toronto

    @Wim Leers

    I am hesitant/concerned about adopting https://turbo.hotwired.dev/ because of the big notice you can see at the top of https://www.drupal.org/project/turbolinks β†’

    They were very aggressive about it.

    For what it's worth, I read through the exchange you had with them and was appalled at how they treated you. Sure, there's some reasonable discussion they could have had about naming and branding, but they threw that out the window.

    Then again … https://github.com/symfony/ux-turbo seems to have been around for a while and they somehow did not get shouted at by the creators of Turbolinks? πŸ™ƒπŸ€·

    It's probably because they use the official Turbo that it's technically okay with them. I think as long as we don't use the Turbo name other than to refer to our own integration with the official Turbo library/framework we should be following their requirements, even if we feel they're overly restrictive/stringent.

    This sounds like it would be impossible to make it work automatically for contrib/custom modules' Drupal.behaviors? πŸ˜…πŸ˜± Sounds like @Ambient.Impact has similar concerns.
    We'd need to figure out a way to make this work transparently, otherwise this seems not viable. (I did not look into what "Stimulus controllers" are.)

    Yeah, I can't really see an easy way to do this automagically that won't break some contrib code. It'd be interesting to explore at some point, but it feels like a whole project in itself. Also, controllers in Stimulus are just JavaScript classes that get automatically attached and detached to various elements. There's a bunch of other stuff that I'm glossing over, but that's how I understand them.

    OMG, it looks like this prototype now already exists!?

    😎

    @Sebastian Hagens

    @Ambient.Impact showed me a video of the prototype through Mastodon a while ago, but I can't find it anymore.

    Just uploaded it now to YouTube: https://www.youtube.com/watch?v=KYd7vQZRqMo

  • Status changed to Postponed 9 months ago
  • πŸ‡¨πŸ‡¦Canada ambient.impact Toronto

    See πŸ“Œ Hotwire Turbo minimum viable implementation Active for more information.

Production build 0.71.5 2024