Accudio / async-alpine

Async Alpine brings advanced code splitting and lazy-loading to Alpine.js components!
https://async-alpine.dev
Apache License 2.0
164 stars 12 forks source link

Current state & stability #24

Closed danharrin closed 2 years ago

danharrin commented 2 years ago

Hey!

Thank you so much for this package, it works great. We're exploring using it for filamentphp/filament v3, as it solves a whole bunch of issues for us. I've just got a couple of questions for you if that's okay...

In the README, it's said to be "experimental". Are you frequently releasing breaking changes that we should be aware of? Or is this outdated advice. Is it suitable to be used on a project with 2.5k+ daily installs?

Also, I saw your Roadmap project. Specifically this card. You mention that it can't be used as a plugin ATM. Before seeing that, I had actually done exactly that, and it seemed to work exactly how I wanted it to. Is this outdated information, or did I do something wrong, or miss something that doesn't work?

Screenshot 2022-10-13 at 14 39 26
Accudio commented 2 years ago

Hi @danharrin! Firstly I'm super keen to see how you get on with it!

In terms of that message, that is specifically regarding the fact the project is not at 1.0 and the API hasn't been very stable until recently. The past couple of minor releases have had breaking changes and a complete rebuild. That said, I am planning a 1.0 release soon (within this calendar year at least, possibly within the next few weeks) and think it's very unlikely I will make further breaking API changes. After 1.0 these would come with a major version bump as per semver.

As for the plugin, the screen shot you have linked works fine. What I mean by that card is I'd love to be able to use Alpine.plugin(AsyncAlpine) as an installation method, as a proper Alpine plugin (like sortable and Floating UI). That's currently not possible, and although there's a PR on the Alpine repo open that would support that, it doesn't look likely to be merged soon. If it is merged however, that would be the long term goal—a few years whilst Alpine support catches up—and would possibly be a rebuild for 2.0 or 3.0.

danharrin commented 2 years ago

Hey, maybe I didn't make this clear, but the screenshot I sent is actually an Alpine plugin?

The export default (Alpine) accepts the Alpine instance, which is passed in by Alpine.plugin(PluginName)

Accudio commented 2 years ago

On interesting, I haven't seen that pattern before! I guess it could be 'wrapped' into a plugin then—I'll have a look into that. Thanks!

I guess then I specifically mean using Alpine's plugin hooks. Currently Async Alpine needs to do it's own processing and it's own mutation observer. If we could add a directive before x-ignore that would mean we could rely on built-in Alpine plugin hooks to massively simplify. But as I say, that would be a while off.

Accudio commented 2 years ago

I've decided that unless Alpine adds functionality so Async Alpine can rely entirely on the Plugin API, I won't be changing the initialisation pattern to Alpine.plugin(AsyncAlpine).

With a complex Async Alpine setup we'd expect people to define a lot within their JS file for Async Alpine and less for Alpine so I think the current API makes the most sense. Of course someone could define their own Alpine plugin if they'd like as @danharrin has done, but I feel it adds additional complexity without benefit.