Repository navigation
Conversation
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>
🤖 PR meta 🤖🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
| @@ -1,4 +1,4 @@ | |||
| # Core Fields | |||
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…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>
#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>
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/andentity-actions/, and teacheswp-buildto build packages from folders other thanpackages/.Why?
Feedback on the recently landed Entity fields and Entity actions APIs was that
@wordpress/core-fieldsand@wordpress/core-actionsare 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, likeroutes/andwidgets/, 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:
wpPlugin.packageDirs.wp-buildonly looked for packages inpackages/*. The newwpPlugin.packageDirsoption in the rootpackage.jsonlists the folders to look in and defaults to[ "packages" ]. Each entry is either a folder of packages (packagesmeanspackages/*) 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.packages/core-fieldstoentity-fields/.git mv, history kept. The workspace is renamed@wordpress/entity-fieldsand 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 tobuild/scripts/entity-fields, whichlib/load.phploads.packages/core-actionstoentity-actions/. The same for actions:@wordpress/entity-actions, script module IDs@wordpress/entity-actions/<collection>(post_type_supports,wp_block,wp_template_part), PHP inbuild/scripts/entity-actions.The root
workspaces,wpPlugin.packageDirs, the private-APIs allowlist, the TypeScript references and the tooling that only knew aboutpackages/*now include both folders: ESLint config and suppressions, the tsconfig and license validators, the clean script, lint-staged, PHPCS, the CInode_modulescache, the e2e build artifact, the labeler and the backport changelog check. The PHP function names and theremove_actioncalls that replace WordPress core's copies are unchanged.packages/fieldsis not touched.Testing Instructions
npm install && npm run build.build/modules/registry.phplists the@wordpress/entity-fields/*and@wordpress/entity-actions/*modules and no@wordpress/core-fields/*or@wordpress/core-actions/*, and thatbuild/scripts/entity-fields/index.phpandbuild/scripts/entity-actions/index.phpexist.GET /wp-json/wp/v2/entity-fields?kind=postType&name=pagelists the@wordpress/entity-fields/post_type_supportsand@wordpress/entity-fields/pagemodules;GET /wp-json/wp/v2/entity-actions?kind=postType&name=pagelists@wordpress/entity-actions/post_type_supports.gutenberg-extensible-site-editorexperiment on, the pages list shows the "Privacy Policy Page" and "Posts Page" badges.npm start, edit a file inentity-fields/srcand one inentity-actions/src, and check both rebuild.npm run test:unit:vitest -- entity-fields entity-actions packages/editor/src/dataviews packages/wp-build, the entity fields/actions PHPUnit tests, andnpm 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.