Skip to content

Entity fields and actions: Move the core packages to top-level entity-fields and entity-actions folders - #84933

Closed
oandregal wants to merge 3 commits into
trunkfrom
update/entity-fields-actions-folders
Closed

oandregal wants to merge 3 commits into
trunkfrom
update/entity-fields-actions-folders

Conversation

@oandregal

Copy link
Copy Markdown
Member

What?

Follow-up to #84696, #84643 and #84660.

Moves the fields and actions WordPress core registers on the server out of packages/ into two top-level folders, entity-fields/ and entity-actions/, and teaches wp-build to build packages from folders other than packages/.

Why?

Feedback on the recently landed Entity fields and Entity actions APIs was that @wordpress/core-fields and @wordpress/core-actions are not really packages of the editor: they hold the PHP declarations and script modules of what WordPress core registers through those APIs. Giving them their own top-level folders, like routes/ and widgets/, keeps them out of the package list and names them after the APIs they serve (wp_register_entity_fields(), wp_register_entity_actions(), /wp/v2/entity-fields, /wp/v2/entity-actions).

None of this has shipped in a release yet, so the script module IDs can change without a back-compat layer.

How?

Three commits:

  1. Build: Build packages from the folders listed in wpPlugin.packageDirs. wp-build only looked for packages in packages/*. The new wpPlugin.packageDirs option in the root package.json lists the folders to look in and defaults to [ "packages" ]. Each entry is either a folder of packages (packages means packages/*) or a single package folder. Every package path now goes through one lookup from folder name to directory (packages/wp-build/lib/package-dirs.mjs), including watch mode. The folder name still names the build output and the script module IDs, so the build fails when two packages share one. README, changelog and tests included.
  2. Entity fields: Move packages/core-fields to entity-fields/. git mv, history kept. The workspace is renamed @wordpress/entity-fields and stays private (no changelog, like routes). Script module IDs become @wordpress/entity-fields/<collection> (attachment, page, post_type_supports, root_site, wp_block, wp_template, wp_template_part), and the PHP builds to build/scripts/entity-fields, which lib/load.php loads.
  3. Entity actions: Move packages/core-actions to entity-actions/. The same for actions: @wordpress/entity-actions, script module IDs @wordpress/entity-actions/<collection> (post_type_supports, wp_block, wp_template_part), PHP in build/scripts/entity-actions.

The root workspaces, wpPlugin.packageDirs, the private-APIs allowlist, the TypeScript references and the tooling that only knew about packages/* now include both folders: ESLint config and suppressions, the tsconfig and license validators, the clean script, lint-staged, PHPCS, the CI node_modules cache, the e2e build artifact, the labeler and the backport changelog check. The PHP function names and the remove_action calls that replace WordPress core's copies are unchanged. packages/fields is not touched.

Testing Instructions

  1. npm install && npm run build.
  2. Check build/modules/registry.php lists the @wordpress/entity-fields/* and @wordpress/entity-actions/* modules and no @wordpress/core-fields/* or @wordpress/core-actions/*, and that build/scripts/entity-fields/index.php and build/scripts/entity-actions/index.php exist.
  3. GET /wp-json/wp/v2/entity-fields?kind=postType&name=page lists the @wordpress/entity-fields/post_type_supports and @wordpress/entity-fields/page modules; GET /wp-json/wp/v2/entity-actions?kind=postType&name=page lists @wordpress/entity-actions/post_type_supports.
  4. Open a post in the post editor: the summary panel fields (status, slug, author, template, …) and the post actions menu work, with no console errors.
  5. Site editor → Pages / Patterns / Templates: the list fields and the item actions (duplicate, rename, export pattern, move to trash, …) work. With the gutenberg-extensible-site-editor experiment on, the pages list shows the "Privacy Policy Page" and "Posts Page" badges.
  6. Run npm start, edit a file in entity-fields/src and one in entity-actions/src, and check both rebuild.
  7. Automated: npm run test:unit:vitest -- entity-fields entity-actions packages/editor/src/dataviews packages/wp-build, the entity fields/actions PHPUnit tests, and npm run test:e2e -- entity-actions-api entity-fields-api.

Use of AI Tools

Claude Code (Claude Opus 5.5) planned and implemented the changes in this PR under my direction, and wrote this description.

oandregal and others added 3 commits October 16, 2026 14:26
wp-build only looked for packages in `packages/*`. The new
`wpPlugin.packageDirs` option lists the folders to look in, relative to
the root `package.json`, and defaults to `[ "packages" ]`. Each entry is
either a folder of packages (`packages` means `packages/*`) or a single
package folder (a folder with its own `package.json`).

Every package path now goes through one lookup from the package folder
name to its directory, including watch mode, which watches the `src`
folder of every package found. The folder name names the build output,
so the build fails when two packages share one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fields WordPress core registers on the server are not a package of
the editor: they are the PHP declarations and script modules of the
Entity fields API. Move them out of `packages/` into a top-level
`entity-fields` workspace named `@wordpress/entity-fields`, matching
`wp_register_entity_fields()` and the `/wp/v2/entity-fields` route.

The script modules become `@wordpress/entity-fields/<collection>`, and
the PHP builds to `build/scripts/entity-fields`, which `lib/load.php`
loads. The workspace stays private and drops its changelog, like the
routes. The private APIs allowlist, the root workspaces and
`wpPlugin.packageDirs`, the TypeScript references, and the tooling that
listed `packages/*` (ESLint, the tsconfig and license checks, the clean
script, lint-staged, PHPCS, the CI cache, build artifacts, labeler, and
backport changelog paths) now include the folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Like the core fields, the actions WordPress core registers on the server
are the PHP declarations and script modules of the Entity actions API,
not a package of the editor. Move them out of `packages/` into a
top-level `entity-actions` workspace named `@wordpress/entity-actions`,
matching `wp_register_entity_actions()` and the `/wp/v2/entity-actions`
route.

The script modules become `@wordpress/entity-actions/<collection>`, and
the PHP builds to `build/scripts/entity-actions`, which `lib/load.php`
loads. The workspace stays private and drops its changelog. The private
APIs allowlist, the root workspaces and `wpPlugin.packageDirs`, the
TypeScript references, the ESLint suppressions, and the tooling wired
for `entity-fields` now include the folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added [Package] Editor /packages/editor [Package] E2E Tests /packages/e2e-tests [Package] Private APIs /packages/private-apis [Package] Fields /packages/fields [Package] wp-build /packages/wp-build labels Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

Comment thread entity-fields/README.md
@@ -1,4 +1,4 @@
# Core Fields

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I went for entity-fields (instead of fields) to prevent collision with the existing @wordpress/fields package. The folder name is used for a number of things by wp-build (script modules, etc.): I don't claim to know them all as this is my first time working with wp-build, but I thought I'd be cautious.

Note that the @wordpress/fields is intended to be used to expose the useFields hook and loadFields loader in a future next step.

// folders listed by `wpPlugin.packageDirs`.
const PACKAGE_DIRS = getPackageDirs(
ROOT_DIR,
WP_PLUGIN_CONFIG.packageDirs ?? DEFAULT_PACKAGE_DIRS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't really consider these top level folder "packages". Instead I'd prefer if they output php with the calls to resister the fields and call in the generated build/build.php automatically. I think the plugin author defining fields shouldn't have to write anything beside the fields them selves.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Worth noting that wp-build is for both gutenberg and third-party plugins so if we add a config like this, we need to ensure it's not a temporary thing.

dmallory42 added a commit to woocommerce/woocommerce that referenced this pull request Oct 21, 2026
…eld registry

Fields were extra properties on the core-data entity config. They now live
in `entity-fields/src/<collection>/<field>/field.ts`, following the layout
of Gutenberg's entity-fields folder (WordPress/gutenberg#84933), and the
route registers them with the editor's private `registerEntityField`. The
stage reads them back with `getEntityFields`.

The public `registerEntityField` in @wordpress/editor is switched off in
WordPress 7.1 core, so this uses the private store until the server-side
Entity Fields API lands. A Jest test runs against the real editor store,
so it fails if WordPress renames or removes those private actions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dmallory42 added a commit to woocommerce/woocommerce that referenced this pull request Oct 27, 2026
#70007)

* feat(settings): Add the experimental payment settings screen with a cheque example

Show a settings form at /settings/$page when a woo_settings_payments
entity with that name is registered through addEntities(). The form
reads its label and fields from the entity config, its layout from View
Config, and saves or discards the one record with core-data.

Cheque is the Core example, on the existing v3 payment gateways
endpoint. Loading the wp-build output moves into AdminScreens, and
PaymentSettingsScreen moves to Internal\Admin\Screens\Settings.

The views catalog moves to 2.0.0 to match DataForm 20, so the lockfile
is pnpm's output as written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(settings): Name the payment settings record in the save review panel

The Cmd+S review panel listed the cheque settings as "Untitled" because the
entity config had no getTitle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(settings): Keep payment settings actions on screen on small viewports

The admin-ui Page header doesn't wrap or shrink its actions, so on phones
the Save button sat past the right edge. Below the medium breakpoint the
Save and Discard buttons now render under the form instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Remove the unused script module registration

The admin-screens build registers no script modules, so loading the build
file is all AdminScreens::load() needs to do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(settings): Remove a test that only covers core-data edit tracking

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Remove the payment settings route loader

The stage already loads the record with useEntityRecord and shows a spinner
until it arrives, so preloading it in the route only duplicated that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(settings): Show the payment settings loading state inside the page

While the record or form layout loaded, the spinner and load errors rendered
outside the admin-ui Page, in the top-left corner. The Page and breadcrumb now
render straight away, with the spinner or error in the content column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(settings): Remove admin notices from the payment settings screen

The generated page hides admin notices with CSS, but notices that set their
own inline display, such as Square's, showed until the app covered them.
The screen now removes notice callbacks before they print, as the existing
Payments settings page does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(settings): Add the instructions field to the cheque settings example

The v3 payment gateways endpoint returns instructions inside `settings` as
a field description with a `value`, but saves the plain value. The field
reads either shape and writes `settings.instructions`, so a save sends only
that setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(settings): Remove the payment settings entity tests

They covered core-data's handling of the entity config and a small field
mapping on the example page, which saving in the browser already checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(settings): Remove the payment settings route test

The route only registers the entities and rejects pages without one, which
loading an unknown page in the browser already shows. Jest now passes when
admin-screens has no tests, as other packages in the monorepo do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Use the monorepo's type overrides in admin-screens

Replace the tsconfig `paths` mapping with the internal-build type overrides
for @wordpress/data and @wordpress/core-data, as email-editor does. The
imports name each override's index file because admin-screens uses Bundler
module resolution, which doesn't resolve the export's directory.

Adding internal-build makes admin-screens a TypeScript project in the
monorepo, so the pnpmfile sets `composite` and the project references.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Remove the resolution selector types from the settings stage

core-data's own types now cover the settings record's resolution error. The
View Config check is gone too: the private getViewConfig selector isn't in
the pinned core-data types, and the screen always has a layout when its
flag is on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Load the admin screens build from AdminScreens

AdminScreens now loads the wp-build output itself, in admin requests and
only while the renamed `experimental-admin-screens` flag is on, so screens
no longer load it. Checking the flag there keeps the build's script handles
and its generated full-screen page off sites with the flag off. The build
file is only loaded when it exists, so a development build that skips
admin-screens no longer breaks the admin.

PaymentSettingsScreen removes the generated full-screen page when it isn't
available, for example without the View Config API. `@since` tags use
11.3.0, the release this foundation is meant for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Register payment settings fields in the editor field registry

Fields were extra properties on the core-data entity config. They now live
in `entity-fields/src/<collection>/<field>/field.ts`, following the layout
of Gutenberg's entity-fields folder (WordPress/gutenberg#84933), and the
route registers them with the editor's private `registerEntityField`. The
stage reads them back with `getEntityFields`.

The public `registerEntityField` in @wordpress/editor is switched off in
WordPress 7.1 core, so this uses the private store until the server-side
Entity Fields API lands. A Jest test runs against the real editor store,
so it fails if WordPress renames or removes those private actions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(settings): Describe where payment settings fields live

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Move entity fields out of src

entity-fields is a folder inside admin-screens, not a package with its own
build like Gutenberg's, so it doesn't need a src level. Jest now compiles
it alongside the routes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(settings): Ignore the recommended components lint on the payment settings screen

The repo-wide rule flags Button and Notice from @wordpress/ui. Allowing
them properly needs the allowUseWithCaution option and newer packages,
so ignore it on this experimental screen for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Type the cheque settings record

The cheque fields used the generic settings record, so the instructions
field needed casts to read its value. Give cheque its own record type
and let registerEntityFields take fields of any record type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(settings): Remove the payment settings field registry test

It mostly tested the editor store's field registry rather than our
code, and that code moves to the Field Collection API before release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(settings): Note the field registry wrapper is temporary

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(settings): Explain the absolute Payments breadcrumb URL

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Use a generic class for the settings content column

Nothing in the column's styles is specific to payments, so other
settings screens can use the same class.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(settings): Remove the payment settings section from the admin screens README

Documentation can follow once the screen is public.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Drop the View Config check from the payment settings screen

The screen only goes live once WordPress 7.1, which adds View Config, is
the minimum supported version, so it doesn't need to handle WordPress
without it. That also removes the code that turned off wp-build's
full-screen page in that case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(settings): Remove the admin screens build loading test

It passed without the build present and skipped itself otherwise, so it
didn't check the flag in practice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(settings): Remove the cheque View Config test

It repeated the layout array from the code rather than checking how the
form behaves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(settings): Rename the payment settings screen to the settings screen

The screen will host more than payment settings, so drop "payment" from
the PHP class, the wp-build route and the page. The page ID is
wc-settings-screen because wc-settings is the classic Settings page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(deps): Update the lockfile for the admin screens dependencies

Trunk's lockfile was taken in the merge; this adds the admin-screens
dependencies and the @wordpress/views 2.0.0 catalog change as pnpm
wrote them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@oandregal oandregal closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] E2E Tests /packages/e2e-tests [Package] Editor /packages/editor [Package] Fields /packages/fields [Package] Private APIs /packages/private-apis [Package] wp-build /packages/wp-build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants