-
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
Interactivity API: Create @wordpress/interactivity-router
module
#57924
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/interactivity-api/class-wp-interactivity-api.php |
Size Change: +204 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
6635608
to
00650c7
Compare
if ( request === '@wordpress/interactivity-router' ) { | ||
// Assumes this is usually giong to be used as a dynamic import. | ||
return `import ${ request }`; | ||
} |
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.
This is the kind of change that I'd like us to improve as part of adding these new modules, we should be adding hacks like this when we create new packages/modules. Instead we should have everything taken care of automatically. How can we do that 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.
Ideally, all the WordPress packages should be available as modules. Once that's done, we can update this to do something similar to what's done for scripts and make any module that starts with @wordpress
external.
This reverts commit e551609.
Flaky tests detected in 980ad9b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7644906646
|
This reverts commit 3e50a84.
…ule' into try/interactivity-api-router-module
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.
Great work. Let's merge it to test it out before WP 6.5 🙂
I noticed this PR was merged after I raised the PHP Sync Tracking Issue for WP 6.5 and has changed PHP files that may need backporting to WP Core. Apologies if you have already mentioned this but could I ask for confirmation as to whether this PR will need a backport? |
Hi @getdave ! The only code that will need backport is the register of the router module.
We are still finishing the definition of how we will register and enqueue script modules in Core. But we are fully aware of this change to be backported in Core for Beta 1. |
Yes, that registration will be part of the backport of this PR, so no need to do anything else here. |
What?
Tracking issue: #56803
Created on top of #57859
Moves all the router-related code to its own module named
@wordpress/interactivity-router
.The module exposes the
navigate
andprefetch
functions previously exported from@wordpress/interactivity
, now as actions of thecore/router
store.As a reference, these are the bundle size results before and after splitting the code.
About the table:
Content-Length
header in HTTP responses.Why?
To start splitting the Interactivity API into separate parts.
How?
router.js
file is moved to its own folder and imports all the required dependencies from@wordpress/interactivity
instead of using relative imports.@wordpress/interactivity-router
module is registered in Gutenberg.@wordpress/interactivity-router
module is added as a dependency of the Query block'sview.js
module.Testing Instructions
interactivity/index.min.js
andinteractivity/query.min.js
have been requested, but notinteractivity/router.min.js
.interactivity/router.min.js
has been requested.