Remove jQuery dependency from @wordpress/api-fetch#8311
Remove jQuery dependency from @wordpress/api-fetch#8311gziolo merged 9 commits intoWordPress:masterfrom mmtr:update/remove-jquery-api-fetch
Conversation
|
Not sure why I'm not receiving any output on the test-e2e run |
|
We still need to properly update dependencies declared in PHP code. It's not the best experience to be honest. I can help with that. |
lib/client-assets.php
Outdated
There was a problem hiding this comment.
I think this addition makes more sense as an addition to the heartbeat script instead of wp-api-fetch
There was a problem hiding this comment.
You would have also to add wp-hooks as a dependency of wp-api-fetch because it is now used in the code.
It might be more tricky to put it as part of heartbeat because of wp-hooks dependency.
There was a problem hiding this comment.
wp-hooks is now a dependency of wp-api-fetch
There was a problem hiding this comment.
I still think ideally, this script should be attached to heartbeat. It's possible to do so https://wordpress.stackexchange.com/questions/100709/add-a-script-as-a-dependency-to-a-registered-script
This allows us to remove the jQuery dependency from the wp-api-fetch script handle as well. Ideally, we would port heartbeat to a gutenberg package and just do it in the code instead of an inline script.
Anyway, I'm fine with this change if we add a comment explaining what we should do ideally.
There was a problem hiding this comment.
Yes, good point. @mmtr let us know if you want to iterate or leave it as it is filing an issue to tackle it later.
There was a problem hiding this comment.
Thanks @youknowriad for the suggestion! 👍
I have moved the addition to the heartbeat script. Does it look good now?
I'm not very familiar yet with PHP or the WordPress API, so it may be possible I forgot something else. Let me know if that it's the case!
What I have not found is where the jQuery dependency is defined for the wp-api-fetch script. Where is it? It looks like only the wp-edit-post script is defining that dependency.
gziolo
left a comment
There was a problem hiding this comment.
There are 2 things to fix and we should be good to go.
Thanks for opening this PR, very anticipated change! 💯
There was a problem hiding this comment.
Can we rename api-fetch/createNonceMiddleware to core/api-fetch/create-nonce-middleware? It would make it more similar to other hooks.
There was a problem hiding this comment.
yeah, it makes sense. renamed!
|
|
- Missing full stop after inline comment - Missing whitespace after "!"
I already did this. Do you miss something? |
|
Looks great, thanks for the last set of improvements 🚢 |
This removes the
jQuerydependency from the@wordpress/api-fetchpackage.The nonce middleware relies now on
@wordpress/hooksfor listening to the heartbeat ticks events.