-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block Library: Improve view script integration to account for WordPress Core #32977
Conversation
35d3b89
to
6057b94
Compare
I have just realized that the implementation in WordPress core won't work with the recent changes to have asset files are generated that was introduced in #31732: gutenberg/packages/dependency-extraction-webpack-plugin/lib/index.js Lines 181 to 184 in 31e6c0c
It's incompatible with how WordPress core detects the asset file: There is no longer in Guteberg We need to either revert the logic that removes |
I think I managed to bring back compatibility for Everything seems to work as expected. |
Size Change: +10 B (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
@jsnajdr or @fullofcaffeine, can you double-check changes applied to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm that pdf previews and responsive navigation still works as expected for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We originally wanted to use the index.asset.php
name:
- because that name was used before the
.min.js
patch, the contents of the file didn't change, and there's no reason to rename the file - there is nothing minified in a
.min.asset.php
file - the
index.asset.php
name is more aesthetic 🙂
But if the Core register_block_script_handle
requires the .min.asset.php
, we need to use it. This patch achieves that and the client-assets.php
and extraction plugin changes are OK.
Yes. I agree it's a bit unfortunate and it would be better if it was taken into account in the original implementation. |
Description
Follow-up for #32814.
Required for WordPress/wordpress-develop#1412.
We are trying a solution that integrates easier with WordPress core. The idea is to introduce
viewScript
in theblock.json
file and shim handling for WordPress 5.7 withblock_type_metadata_settings
hook for WordPress core blocks.This solution won't work with WP 5.6 but we will phase it out in 2-3 plugin releases anyway when WP 5.8 is out. So I think it's a good compromise.
How has this been tested?
I tested with the Navigation block and its "Enable responsive menu" option enabled in the sidebar menu.
Once you insert the block, enable the option. It has to be tested on the front end on small viewports.
It should be tested also with the File block and embed previews for PDF files.
Screenshots
Script handles should be also printed at the end of the HTML source when visiting the published post:
Types of changes
Bug fix (non-breaking change which fixes an issue).
Checklist:
*.native.js
files for terms that need renaming or removal).