Skip including inactive or experimental routes when building for WordPress Core#76715
Skip including inactive or experimental routes when building for WordPress Core#76715
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to ensure that WordPress Core builds only include assets for active (non-experimental) pages/routes, so inactive/experimental routes aren’t built and therefore aren’t bundled into the resulting wordpress-develop assets.
Changes:
- Filter the route build phase to only build routes whose
route.pageis in the active page set (with Core builds excludingexperimentalpages). - Refactor script/module registry generation to inline dependency/version metadata rather than referencing generated
.asset.phpfiles. - Switch style dependency inference to use in-memory script dependency data (instead of parsing
.asset.phpoutput).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| plugins: [ | ||
| ...baseBundlePlugins, | ||
| wordpressExternalsPlugin( | ||
| 'index.min', | ||
| 'iife', | ||
| packageJson.wpScriptExtraDependencies || [], | ||
| true // Generate asset file for minified build | ||
| false, // Do not generate asset file; data goes into registry.php | ||
| scriptAssetResult | ||
| ), |
There was a problem hiding this comment.
wordpressExternalsPlugin currently only accepts 4 parameters (assetName, buildFormat, extraDependencies, generateAssetFile). The extra scriptAssetResult/moduleAssetResult arguments are ignored, and when generateAssetFile is false the plugin returns early in onEnd before computing dependencies/module_dependencies/version. As a result, scriptAssetResult/moduleAssetResult stay empty and the generated registries will have missing deps and a potentially undefined version (and styles inference will see no script deps). Either keep generateAssetFile: true and continue reading the asset file, or update the externals plugin to always compute deps/version and optionally write them into a provided result container when generateAssetFile is false.
| `\tarray(\n` + | ||
| `\t\t'id' => '${ module.id }',\n` + | ||
| `\t\t'path' => '${ module.path }',\n` + | ||
| `\t\t'asset' => '${ module.asset }',\n` + | ||
| ( module.min_only ? `\t\t'min_only' => true,\n` : '' ) + | ||
| `\t),` | ||
| ) | ||
| `\t\t'dependencies' => array(${ depsPhp }),\n` + | ||
| `\t\t'module_dependencies' => array(${ moduleDepsPhp }),\n` + | ||
| `\t\t'version' => '${ module.version }',\n`; | ||
| if ( module.min_only ) { | ||
| entry += `\t\t'min_only' => true,\n`; | ||
| } | ||
| entry += `\t),`; |
There was a problem hiding this comment.
generateModuleRegistrationPhp no longer emits an 'asset' key for each module, but the generated PHP registration code still expects $module['asset'] to locate and require the .asset.php file (see packages/wp-build/templates/module-registration.php.template). With this change, module registration will hit an undefined index and lose module dependency/version data. Update the templates/registration logic to read the inlined dependencies/module_dependencies/version fields (or keep writing asset files and keep the existing template contract).
| `\t\t'dependencies' => array(${ depsPhp }),\n`; | ||
| if ( moduleDepsPhp ) { | ||
| entry += `\t\t'module_dependencies' => array(${ moduleDepsPhp }),\n`; | ||
| } |
There was a problem hiding this comment.
generateScriptRegistrationPhp no longer emits an 'asset' key for each script, but packages/wp-build/templates/script-registration.php.template still reads $script_data['asset'] and requires the corresponding .asset.php to get dependencies/version. This will produce an undefined index error and will register scripts without the intended metadata. Either update the template to use the new dependencies/module_dependencies/version fields from the registry, or keep generating .asset.php files and the 'asset' field.
| } | |
| } | |
| if ( script.asset ) { | |
| entry += `\t\t'asset' => '${ script.asset }',\n`; | |
| } |
| packageJson.wpScriptExtraDependencies || [], | ||
| true // Generate asset file for minified build | ||
| false, // Do not generate asset file; data goes into registry.php | ||
| scriptAssetResult |
There was a problem hiding this comment.
This change disables generating .asset.php files for package scripts/modules and switches the registries to embed dependency/version data directly. That’s a much broader contract change than the PR description (which is focused on excluding inactive/experimental routes from Core builds) and will require coordinated updates to the PHP templates/consumers (and possibly downstream tooling) to avoid breaking builds.
|
Size Change: 0 B Total Size: 7.66 MB ℹ️ View Unchanged
|
What?
This stops including experimental or inactive routes when building assets for WordPress Core.
Why?
In the assets built for
wordpress-develop, all routes and their respective files are included in the zip file even though the generatedregistry.phpfile only contains active, non-experimental routes. This results in thewordpress-developbuild script copying them and including them in packages.This aims to skip including them at all, which saves time building the plugin zip, saves bandwidth and disk space uploading and downloading the built asset form the GitHub Container Registry, and avoids having to either keep an include or exclude list for routes or the need to parse the
registry.phpfile to determine which routes to include.Use of AI Tools
Tools: Claud Code
Model: Sonnet 4.6
Description: Used Claude to investigate, formulate a plan, and create the first draft PR.