ViewScriptModule: 6.5 compatibility changes#58832
Conversation
|
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/compat/wordpress-6.5/scripts-modules.php ❔ lib/experimental/script-modules.php |
There was a problem hiding this comment.
In WordPress trunk we no longer require the asset file to be present.
There was a problem hiding this comment.
This handles the deprecated viewModule field. Core >= 6.5 handles viewScriptModule.
There was a problem hiding this comment.
This is moved to trunk or the compat file.
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
4091040 to
f82922e
Compare
What?
viewScriptModuleblock.json field support has landed in Core 6.5 (WordPress/wordpress-develop#5860 / https://core.trac.wordpress.org/changeset/57565).Move
viewScriptModulesupport in Gutenberg to 6.5 compatibility.viewModulesupport and theview_module_idsREST API field are maintained in Gutenberg regardless of the WordPress version.Testing Instructions
Test with latest WordPress 6.4.3 and WordPress trunk. Try these steps with
viewModule,viewScriptModuleand both.Add a block using
block.jsonwith a (viewModule,viewScriptModule, both) field pointing to its view module. I've compiled a block (with #57461) that's available at this gist. It can be unzipped as a plugin and used for testing.We should be able to add our block in the editor. If we use the REST API to query block types and search for
view_module_idsandview_script_module_idswe should find our block:If the block is added to a post and we visit it on the frontend, we should see it working as expected (a counter in our example).
We should also see the expected modules added to the importmap and module preloads on our post with the block. I used an older theme to ensure nothing else was enqueuing the interactivity module: