Tracking issue: Directives Hydration ⚛️
luisherranz opened this issue · comments
We are now actively working on the WordPress Directives Plugin Tracking issue instead ➡️
This issue aims to list and keep track of the tasks related to the Directives Hydration experiment.
For the Custom Elements Hydration experiment, please check the Tracking Issue: Custom Elements Hydration 🧩.
The main branch of this experiment is main-directives-hydration
. Make sure you select it when opening a pull request if it is related to this experiment.
Please, proactively comment on this issue whenever you start working on a new task, get blocked, or finish a task, sharing as much detail and information as possible. Thanks!!
Experiments
- WordPress/gutenberg#44034
- woocommerce/woocommerce-blocks#7187
- WordPress/gutenberg#44509
- DAreRodz/js-framework-benchmark#1
Done
Next
On hold
I've made a proof of concept of the vdom-based client-side navigation on the Query Loop block:
I've made some more progress on the experiment, replacing the imperative event listeners with a wp-client-navigation
directive and adding a small client router that caches the HTML and can prefetch pages:
So far so good!
The "block wiring" is almost complete; I marked #66 ready for review. Still, I have intentionally left the block context to implement it in a different PR and test the preact's option hook API.
There's also a problem during hydration, because some elements are being regenerated. We need to investigate that. 🕵️
EDIT: the hydration bug was found. I left a note in the bugfix.
I refactored toVdom()
, removed visitor.js
and added directives support. In addition, most of the code that was inside visitor.js
has been moved to directives.
David is working on Suspense
and ErrorBoundaries
in this PR:
I've started another client-side navigation experiment for WooCommerce's Product Query block. This one is replacing only the inner children of the Product Query block instead of the whole document.
I've removed the <wp-block>
wrapper and everything seems to work fine. 🙌
The way to append the wrapper attributes is a bit hacky, TBH. We can give it a thought and change that with something else.
do you mind if I refactor the directives code a bit to make it work with
wp-directive
instead ofdata-wp-block-directive
?
Of course I don't mind! Actually, I thought of doing the same, hehe. 😄
I've written an update on the lazy hydration techniques issue:
TL;DR: all the approaches we tried so far were unsuccessful, although we have some ideas we're going to explore next week.
We decided to put #75 on hold as mentioned in #75 (comment), and continue with other tasks.
Also, I've created an issue for removing the wp-inner-blocks
wrapper, which is what I'm going to work on.
@ockham and I recorded a video summary of the progress with this.
@SantosGuillamot, @DAreRodz and I have started this new experiment to see if we can replicate the behavior of the Navigation block with directives hydration:
It's based on @SantosGuillamot's initial exploration using Alpine directives.
I think we've finished pretty much here.
@DAreRodz, is there something else we should add?
In a pair-programming session with @c4rl0sbr4v0, we implemented a way to pause hydration if View components are not registered yet.
Merged 🙂
I think we've finished pretty much here.
DAreRodz, is there something else we should add?
Uhm, I'm not sure what else we could add. 😄
Maybe we can test if the directives hydration approach could get along with third-party blocks using other libraries for interactivity. As long as they don't interact with our VDOM, the hydration is supposed to work fine, although we haven't tested yet if that assumption is correct.
I've started working on a benchmark to measure WP directives performance.
I placed a link in the description under Experiments. Feel free to move it if you feel there's a better place for it.
We've moved our work to the WP Directives Plugin branch and Tracking Issue because we are now trying to build a plugin that people can install to test this out.
We have renamed this to Directives Hydration to make more explicit the difference between this and the Custom Elements Hydration.
Closed in favor of: