Skip to content

Try: move core fields/actions to fields package - #84931

Closed
oandregal wants to merge 4 commits into
trunkfrom
update/remove-core-fields-actions-packages
Closed

oandregal wants to merge 4 commits into
trunkfrom
update/remove-core-fields-actions-packages

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 the private @wordpress/core-fields and @wordpress/core-actions packages into the existing @wordpress/fields package, and removes MediaEdit from @wordpress/fields in favour of the @wordpress/media-utils copy.

Why?

Feedback on the recently landed Entity fields and Entity actions APIs was that their server-side definitions are better served by living in the existing @wordpress/fields package than in two new packages. None of this has shipped in a release yet, so the script module IDs and package layout can still change without a back-compat layer.

@wordpress/fields had little left after #84897 and #84643: only MediaEdit, which @wordpress/media-utils already exposes as a private API (#84046). Dropping the duplicate leaves @wordpress/fields with one job, holding the fields and actions core registers, and keeps it a script module package instead of a mix of a bundled npm entry and script modules.

How?

Four commits:

  1. Build: Let a script module export declare its own ID. A wpScriptModuleExports value can now be { "path": "...", "id": "..." } as well as a path. The id replaces the generated @<namespace>/<package>/<key> ID; the output path still comes from the export key. The build fails when two script modules register the same ID, and when code statically imports an export that has its own id (such modules are loaded at runtime with import( id )). Helpers live in packages/wp-build/lib/script-module-utils.mjs, with tests, README and changelog.
  2. Site Editor: Use the MediaEdit private API of @wordpress/media-utils. The site identity panel (site editor) and the identity route (extensible site editor) now render the media-utils MediaEdit. The identity route unlocks it through the shared @wordpress/routes-lock-unlock. The @wordpress/fields stylesheet includes are removed: wp-edit-site now depends on the wp-media-utils style, and the extensible site editor already loads it through wp-editor. The design system focus ring that only the @wordpress/fields copy had (MediaEdit: Use design system focus ring #83854) is ported to media-utils; the copies otherwise differed only in class names, imports and doc comments.
  3. Fields: Hold the core entity fields instead of MediaEdit. packages/core-fields/src moves to packages/fields/src/entity-fields (git mv, history kept). The script module IDs become @wordpress/fields/<collection> (attachment, page, post_type_supports, root_site, wp_block, wp_template, wp_template_part). MediaEdit and MediaEditProps are removed, so @wordpress/fields exports only ./package.json and leaves BUNDLED_PACKAGES of the dependency extraction plugin. lib/load.php loads build/scripts/fields/entity-fields/index.php.
  4. Fields: Hold the core entity actions. packages/core-actions/src moves to packages/fields/src/entity-actions. Through the per-export id, their script modules keep a separate namespace: @wordpress/actions/<collection> (post_type_supports, wp_block, wp_template_part). lib/load.php loads build/scripts/fields/entity-actions/index.php.

The two workspaces, their private-APIs allowlist entries, tsconfig references, labeler entries and unreleased changelog entries are removed or rewritten; their lint suppressions follow the files. The PHP function names and the remove_action calls that replace WordPress core's copies are unchanged.

Breaking for npm consumers of @wordpress/fields: MediaEdit and MediaEditProps are removed, listed in the package changelog next to the fields and actions already removed in this release cycle.

Testing Instructions

  1. npm install && npm run build.
  2. Check build/modules/registry.php lists @wordpress/fields/* and @wordpress/actions/*, and no @wordpress/core-fields/* or @wordpress/core-actions/*.
  3. GET /wp-json/wp/v2/entity-fields?kind=postType&name=page lists the @wordpress/fields/post_type_supports and @wordpress/fields/page modules; GET /wp-json/wp/v2/entity-actions?kind=postType&name=page lists @wordpress/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.
  6. Site editor → Design → Identity (site identity panel): pick, replace and remove the site logo and site icon; the media controls look as on trunk, including the focus ring when tabbing to them.
  7. With the gutenberg-extensible-site-editor experiment on, repeat step 6 on the identity route.
  8. Automated: npm run test:unit:vitest -- packages/fields packages/editor/src/dataviews packages/media-utils 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 generated this summary. I reviewed the plan and the changes.

oandregal and others added 4 commits October 16, 2026 13:32
A `wpScriptModuleExports` value can now be `{ "path": "...", "id": "..." }`
besides a path. The `id` replaces the `@<namespace>/<package>/<key>` ID the
build generates; the output path still comes from the export key.

The build fails when two script modules, in the same package or in
different ones, register the same ID, since one would silently shadow the
other in the generated registry.

Importing an export with an `id` through the package name fails the build:
the import would name a module that is never registered. Such modules are
loaded at runtime with `import( id )`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The site identity panel of the site editor and the identity route of the
extensible site editor rendered the `MediaEdit` copy of `@wordpress/fields`.
Both now render the one `@wordpress/media-utils` exposes as a private API,
the last consumers of the `@wordpress/fields` copy.

The media-utils stylesheet replaces the `@wordpress/fields` one both
included: `wp-edit-site` now depends on the `wp-media-utils` style, and the
extensible site editor already loads it through `wp-editor`. The identity
route unlocks the private API with the shared routes lock-unlock.

Ported to the media-utils copy: the design system focus ring the
`@wordpress/fields` copy received in #83854 after media-utils copied it
(`outset-ring__focus()` on the picker buttons, with the offset for the
grouped compact buttons, instead of the `box-shadow` ring). The copies
differed otherwise only in class names, imports and doc comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`@wordpress/fields` now holds only the fields WordPress core registers on
the server for the Entity fields API, moved from the private
`@wordpress/core-fields` package into `src/entity-fields`, history kept.
Its script modules are `@wordpress/fields/<collection>` (attachment, page,
post_type_supports, root_site, wp_block, wp_template, wp_template_part),
generated from the export keys.

`MediaEdit` and `MediaEditProps`, the last exports of the package, are
removed: nothing uses them since the site editor switched to the
`@wordpress/media-utils` private API. The package has no JavaScript entry
point and no stylesheet any more, so:

- `package.json` exports only `./package.json`, with the
  `wpScriptModuleExports` and `wpCopyFiles` of the old core-fields
  package. `module` stays, pointing at one collection like core-fields did,
  because wp-build only emits `build-module` for packages declaring it.
- It leaves `BUNDLED_PACKAGES` of the dependency extraction plugin and the
  private-APIs exceptions for bundled packages, and its stale lint
  suppressions are pruned.
- `lib/load.php` loads `build/scripts/fields/entity-fields/index.php`.

The `@wordpress/core-fields` workspace, its allowlist entry and its
unreleased changelog entry are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the actions WordPress core registers for its entities from the
private `@wordpress/core-actions` package into `src/entity-actions` of
`@wordpress/fields`, history kept, so one package holds the fields and
actions core registers on the server.

Their script modules keep an `@wordpress/actions/<collection>` ID
(post_type_supports, wp_block, wp_template_part) through the per-export
`id` of `wpScriptModuleExports`; they are built to
`build/modules/fields/entity-actions/`. `lib/load.php` loads
`build/scripts/fields/entity-actions/index.php`, and still removes the
callback WordPress core hooks for its own copy.

The `@wordpress/core-actions` workspace, its allowlist entry and the
unreleased changelog entries naming it are removed or rewritten, and its
lint suppressions follow the files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oandregal oandregal self-assigned this 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.

@github-actions github-actions Bot added [Package] Editor /packages/editor [Tool] Dependency Extraction Webpack Plugin /packages/dependency-extraction-webpack-plugin [Package] E2E Tests /packages/e2e-tests [Package] Edit Site /packages/edit-site [Package] Media Utils /packages/media-utils [Package] Private APIs /packages/private-apis [Package] Fields /packages/fields [Package] wp-build /packages/wp-build labels Oct 16, 2026
@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] Edit Site /packages/edit-site [Package] Editor /packages/editor [Package] Fields /packages/fields [Package] Media Utils /packages/media-utils [Package] Private APIs /packages/private-apis [Package] wp-build /packages/wp-build [Tool] Dependency Extraction Webpack Plugin /packages/dependency-extraction-webpack-plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant