Only include files for active, stable routes#11318
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Pull request overview
Updates the Gutenberg build integration so WordPress Core only bundles route files corresponding to the stable/active routes listed in gutenberg/build/routes/registry.php, instead of copying all route files from the Gutenberg artifact.
Changes:
- Remove route-related globs from the existing
copy:gutenberg-phpandcopy:gutenberg-jstargets. - Add a new
copy:routestarget that builds itssrclist based on route names parsed fromgutenberg/build/routes/registry.php. - Include
copy:routesin thebuild:gutenbergtask sequence.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Also switches off `var` in favor of `const`/`let`.
|
Merged in r62079. |
| 'Route registry not found at ' + registryPath + '. Run `grunt gutenberg:download` first.' | ||
| ); | ||
| } | ||
| const namePattern = /'name'\s*=>\s*'([^']+)'/g; |
There was a problem hiding this comment.
Can this rely on PHP being available? It would be nice to do do something like php -r '$route_registry = include __DIR__ . "/gutenberg/build/routes/registry.php"; echo json_encode( $route_registry, JSON_UNESCAPED_SLASHES );' and work with the data in JavaScript rather than pattern matching PHP code.
There was a problem hiding this comment.
Can this rely on PHP being available?
Good question. I don't know that we can. But I agree that would be preferable.
I should have noted this in the PR and the commit message, but my intention is for this to be a temporary fix. The real problem is that the wp-build package is including these files at all when the context does not ask for experimental or inactive routes. I opened WordPress/gutenberg#76715 to explore this, but it became clear that would have not been ready in time.
The built
gutenbergasset currently includes the files for all routes in the Gutenberg plugin, even experimental and inactive ones. However, theregistry.phpfile only references the routes that should be bundled in Core correctly.This collects all of the
grunt copylogic related to routes into a newcopy:routestask and adjusts thesrclist to only include files related to the routes specified in theregistry.phpfile to avoid unintentionally including files that were not meant to be considered stable.Trac ticket: Core-64393.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Sonnet 4.6
Used for: Created the initial first draft of the PR based a description of the problem and desired outcome.
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.