create-block-interactive-template: Enhance block registration by using blocks-manifest for improved performance#76317
Conversation
|
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. |
|
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. |
|
Size Change: 0 B Total Size: 6.89 MB ℹ️ View Unchanged
|
What?
Closes #74701
Updates
@wordpress/create-block-interactive-templateto usewp_register_block_types_from_metadata_collection()for block registration.Why?
The interactive template still used the legacy
register_block_type_from_metadata(), while the maincreate-blocktemplate already uses the efficient registration APIs from WordPress 6.8.How?
$slug.php.mustache— Replacedregister_block_type_from_metadata()withwp_register_block_types_from_metadata_collection().index.js— Added--blocks-manifestto custom build/start scripts soblocks-manifest.phpgets generated.index.js— AddedfolderName: './src/$slug'so the build output uses the correct directory structure for the manifest.Testing Instructions
npx @wordpress/create-block@latest --template ./packages/create-block-interactive-templatecdinto the plugin, runnpm run buildbuild/<slug>/blocks-manifest.phpexists with the correct block slug as key