-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
WIP: Update npm packages to latest versions for 6.4 Beta 1 #5262
Conversation
This is a potential fix for the |
There is a mismatch with the type of files that are enqueued in the frontend. When you run It looks like in On the other hand, I've manually copied the files and they work fine when they match (both are development or both are production), so the new Webpack configuration seems to have worked well and I don't think we'll need to make any further adjustments. |
It looks like those files are hardcoded in the "viewScript": "file:./view.min.js", So for the moment, instead of honoring the development/production mode, let's always enqueue the production version of the Interactivity API runtime to match what the blocks are doing. @mikachan, you can cherry-pick this commit to fix this: luisherranz@facb976 |
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.
Thanks for getting this started! Looks like we'll need to make a few more changes in Gutenberg and republish the packages. I'm not quite sure why, but removing the sync package and rebuilding is causing neither editor to load in my local env. Can anyone reproduce this?
It looks like those files are hardcoded in the block.json:
These changes will also have to be made in Gutenberg.
These two files can be removed now because the
Apart from that, the new Webpack configuration is adding two unnecessary files to the
I guess it'd be better to delete them. We can do so using this: luisherranz@9ad3846 |
Co-Authored-By: Luis Herranz <3305402+luisherranz@users.noreply.github.com>
Co-Authored-By: Luis Herranz <3305402+luisherranz@users.noreply.github.com>
Co-Authored-By: Luis Herranz <3305402+luisherranz@users.noreply.github.com>
Thanks everyone for all the help here. I think I've cherry-picked all the changes you mentioned, @luisherranz. The sync script is now running successfully 🎉, but I know we need a fresh GB 16.7 RC as well. I can cherry-pick the new GB PRs and trigger a build as soon as all the needed changes are merged. |
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
# Conflicts: # package-lock.json # package.json # src/wp-includes/assets/script-loader-packages.min.php # src/wp-includes/blocks/file/view.asset.php # src/wp-includes/blocks/file/view.min.asset.php # src/wp-includes/blocks/navigation/view.asset.php # src/wp-includes/blocks/navigation/view.min.asset.php # src/wp-includes/blocks/search/view.asset.php
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.
A couple things still need to be addressed; I'm mostly concerned about the sync package. We should remove it, which will require a few more changes in Gutenberg. Can we hold off on republishing the packages until this is sorted out?
This reverts commit 5d0827c.
…tandards workflow." This reverts commit b7614a2.
This reverts commit 6e02a73.
…rds in `phpunit/tests/media.php`." This reverts commit 89f228b.
…ed for loading optimization attributes." This reverts commit 99a2b31.
This reverts commit f92ba90.
This reverts commit 670ab40.
…add `decoding="async"` to images." This reverts commit 6bbce3a.
…archives." This reverts commit ef7fa1c.
This reverts commit 0eae815.
…cript_tag()`/`wp_print_inline_script_tag()` helper functions to output scripts on the frontend and login screen." This reverts commit a6bf745.
This reverts commit 4e4b94a.
…moving." This reverts commit d87f9b8.
This reverts commit 76ea238.
…lls to `wp_add_inline_style`." This reverts commit 1e1ed26.
…se writes in `update_option()`." This reverts commit 75c3843.
This reverts commit 219483f.
This reverts commit 3cea4be.
# Conflicts: # src/wp-includes/assets/script-loader-packages.min.php # src/wp-includes/blocks/file/view.min.asset.php # src/wp-includes/blocks/search/view.min.asset.php
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.
One more non-blocking recommendation.
Given the beta timeline, I don't want to hold up this PR, but it would be great to consider this change prior to the next beta.
// Add the private version of the Interactivity API manually. | ||
$scripts->add( 'wp-interactivity', '/wp-includes/js/dist/interactivity.min.js' ); | ||
did_action( 'init' ) && $scripts->add_data( 'wp-interactivity', 'strategy', 'defer' ); |
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.
Per my response in #5262 (comment), given we want to avoid exposing this API too much until it's stable, how about we don't register it unconditionally?
We could introduce a function like this:
function _wp_maybe_enqueue_interactivity() {
if ( wp_script_is( 'wp-interactivity' ) ) {
return;
}
wp_enqueue_script(
'wp-interactivity',
'/wp-includes/js/dist/interactivity.min.js',
array(),
false,
array( 'strategy' => 'defer' )
);
}
That function could then be called in all the blocks where it is needed, and with such an approach the use of the wp-interactivity
script would be more obviously discouraged.
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.
cc. @luisherranz for your thoughts here.
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.
Thanks for the ping, @mikachan 🙂
given we want to avoid exposing this API too much until it's stable, how about we don't register it unconditionally?
-
If your worries are about third-party scripts accessing the exports that are inside of that JavaScript file:
That file is generated by Webpack as an independent chunk. Only the entry points generated in the same webpack config have the correct auto-generated ID to access those exports.
I'm happy to explore other additional measures. For example, I also tested a random ID that changes each time Webpack runs, although it didn't feel necessary to me as accessing a private Webpack generated chunk is already very hacky and there's no guarantee that the auto-generated ID won't change either.
-
If your worries are about having a script that sometimes is registered unnecessarily and you would prefer to make sure that it's only registered if it's finally enqueued: sure, we can try to add logic to check for that 🙂
Just let me know and I'll take care of it as soon as possible.
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.
Related to the random ID:
Closing as https://core.trac.wordpress.org/changeset/56710 has committed the package updates. |
Trac ticket: https://core.trac.wordpress.org/ticket/59411
This PR includes changes from #5235 & #5195.
I'm currently seeing the following error:
I'm not sure if there are any other missing changes that should be included in this PR - perhaps that's all that's missing for the sync script to run successfully.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.