Skip to content

Only include files for active, stable routes#11318

Closed
desrosj wants to merge 8 commits into
WordPress:trunkfrom
desrosj:skip-unneeded-route-files
Closed

Only include files for active, stable routes#11318
desrosj wants to merge 8 commits into
WordPress:trunkfrom
desrosj:skip-unneeded-route-files

Conversation

@desrosj
Copy link
Copy Markdown
Member

@desrosj desrosj commented Mar 20, 2026

The built gutenberg asset currently includes the files for all routes in the Gutenberg plugin, even experimental and inactive ones. However, the registry.php file only references the routes that should be bundled in Core correctly.

This collects all of the grunt copy logic related to routes into a new copy:routes task and adjusts the src list to only include files related to the routes specified in the registry.php file 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.

@desrosj desrosj self-assigned this Mar 20, 2026
@github-actions
Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props desrosj.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@desrosj desrosj changed the title Only include files for the registered routes. Only include files for active, stable routes Mar 20, 2026
@desrosj desrosj requested review from Copilot, mcsf and sirreal and removed request for Copilot and mcsf March 20, 2026 14:46
@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-php and copy:gutenberg-js targets.
  • Add a new copy:routes target that builds its src list based on route names parsed from gutenberg/build/routes/registry.php.
  • Include copy:routes in the build:gutenberg task sequence.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Gruntfile.js Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Gruntfile.js
Comment thread Gruntfile.js
Comment thread Gruntfile.js
@desrosj
Copy link
Copy Markdown
Member Author

desrosj commented Mar 20, 2026

Merged in r62079.

@desrosj desrosj closed this Mar 20, 2026
@desrosj desrosj deleted the skip-unneeded-route-files branch March 20, 2026 16:32
Comment thread Gruntfile.js
'Route registry not found at ' + registryPath + '. Run `grunt gutenberg:download` first.'
);
}
const namePattern = /'name'\s*=>\s*'([^']+)'/g;
Copy link
Copy Markdown
Member

@sirreal sirreal Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

@desrosj desrosj Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants