Skip to content

Build configuration and versioning

Most of what godmin needs from your build is this config:

import { godminDedupe, godminSingleCopy, godminStylesheetFirst } from '@gopherium/godmin/vite'
export default defineConfig({
resolve: { dedupe: godminDedupe },
plugins: [godminSingleCopy(), godminStylesheetFirst()],
})

This page explains what each part does, then covers stylesheet linting and versioning.

Your bundle must contain exactly one copy of React and of each package godminDedupe lists. Two copies of React crash on the first hook. Two copies of these fail with no error:

  • @wordpress/theme renders components unthemed.
  • @wordpress/i18n renders English. One copy of the runtime explains why.
  • @wordpress/date leaves the DataViews date filters in English, on the wrong clock. The list dates set up one copy, and the filters read the other.
  • @gopherium/react-auth keeps a configured transport that half the app cannot see.

The config handles this twice:

  • godminDedupe makes Vite resolve each listed package once.
  • godminSingleCopy() fails the build, naming the package and both paths, if a duplicate got through anyway.

Nothing renders until your stylesheet arrives, and bundlers request it after the JavaScript. godminStylesheetFirst() moves it first.

How much that helps depends on how much JavaScript competes with it. In one app with eight preloads it cut the blank page from 1.9s to 1.3s. In another with two preloads it changed nothing, because nothing was queueing. It costs nothing at runtime, so leave it on and let it matter as your bundle grows.

On a bundler that is not Vite or Rollup, the underlying functions duplicateCopies and hoistStylesheet are exported so you can wire both checks into whatever hooks it offers.

@wordpress/theme ships three stylelint rules. This turns them on:

export default { extends: ['@gopherium/godmin/stylelint'] }

They catch design tokens that do not exist (a typo renders nothing, with no error), redefined --wpds- properties, and hand-typed fallback values.

Each godmin release supports one design system window, written out in full in its peer ranges as the first version it accepts and the first one it refuses, such as >=0.25.0 <0.26.0. The window moves forward with the design system and never widens, so no release accepts two incompatible generations at once.

The window is exported for your tests:

import { SUPPORTED_WPDS } from '@gopherium/godmin'

SUPPORTED_WPDS names the @wordpress/ui and @wordpress/theme windows only. The other design system peers, @wordpress/icons, @wordpress/a11y and @wordpress/style-runtime, have their windows in the peer ranges of godmin’s package.json.

@wordpress/i18n is a required peer, because the main entry translates godmin’s own words. @wordpress/date is an optional peer, needed only by @gopherium/godmin/dates. Install it next to godmin when you use that entry. Its window is in the same peer ranges. godmin never imports @wordpress/components.

@wordpress/dataviews is an optional peer as well, in the window >=21.0.0 <22.0.0. No godmin entry imports it, but offeredView follows the filter rules of that DataViews release. A list built on another release gets a peer warning when it installs godmin.

godmin 0.32.0 draws ConfirmDialog on the alert dialog of the design system and FormDialog on its dialog, a confirm or a form on a list becomes a dialog your screen renders, and the dialogs move to the main entry. Change your code in these places:

  • @gopherium/godmin/dialogs is gone. Import ConfirmDialog, FormDialog, DialogAnswer and their props types from @gopherium/godmin. godmin no longer has @wordpress/components as a peer. An app that draws DataViews keeps it, since DataViews needs it.
  • ConfirmDialog takes the question as title and what will happen as description, in place of children. size is gone, since a confirm has one width and is a card at every width. Pass intent="irreversible" for an action that cannot be undone, which draws its button red.
  • RunConfirm, ConfirmBody, RunConfirmProps and ConfirmBodyProps are gone. Give the list action a callback that stores the rows, drop its RenderModal, hideModalHeader and modalFocusOnMount, and render a ConfirmDialog from your screen whose onConfirm returns the run, as running an action over the picked rows shows.
  • FormBody, FormKind, RenameBody, useCloseWhileOpen, FormBodyProps and RenameBodyProps are gone. Give the row action a callback that stores the rows, drop its RenderModal, modalHeader, modalSize and modalFocusOnMount, and render a FormDialog or a RenameDialog from your screen whose onSubmit returns the write of useDialogRun, as renaming an item shows. Stop closing the dialog before its write.
  • A rename keeps Save on with a blank field, and the browser refuses the send. A test that read Save off reads that a press on it sends nothing.
  • A confirm is now an alertdialog. A test that finds it by the role dialog finds it by alertdialog.
  • A confirm has no close button now, even with a title. A test that pressed its close button presses Cancel instead.
  • onClose runs once the card has left the page, not at the press. A test that reads the dialog gone, or onClose called, right after a press waits for it, such as with waitFor.
  • Escape and Cancel close nothing while the write runs, and a click on the dimmed page never closes a confirm. A test that dismissed a busy confirm, or clicked outside one, lets the write end or presses Cancel instead. Give a write that can hang a timeout.
  • A promise that rejects, or a handler that throws, leaves the confirm open, and the error still goes on to your app. To close it, catch the failure inside onConfirm and show it in a toast, as a failure from a dialog shows.
  • A handler that returns, or a promise that ends with, an object whose error holds words, or whose close is false, now keeps the confirm open. Turn such an answer into one that closes when your app wants it to close.
  • Any object with a then method now counts as a promise, so the confirm waits for it. Before, it waited only for a real Promise and closed at once for anything else.
  • A stylesheet that styles .godmin-modal-body, its --copy and --create forms, or .godmin-modal-body__question styles nothing now.
  • FormDialog has no kind and no size. It has one width, it is a card at every width, and its footer sets the space above its buttons.
  • FormDialog closes itself. Return nothing from onSubmit to close at once, or the write’s promise to close when it ends, and stop closing it from your handler. Take it away in onClose, which runs once the card has left the page.
  • A form write that fails shows inside the dialog. Answer { error } with words from onSubmit, in place of a toast, as a failure from a dialog shows. A promise that rejects, or a handler that throws, leaves the form dialog open, and the error still goes on to your app.
  • Cancel, the close icon, Escape and a click on the dimmed page close nothing while a form writes. A test that dismissed a busy form dialog lets the write end instead.
  • The close button of a form dialog is now a close icon named “Close” beside the title, and Cancel draws an outline.
  • The send button of a form dialog sits in the footer, outside the form, and names it. user-event in jsdom finds no send button for Enter there, so a test that typed Enter in a field presses the send button instead, or runs in a browser.

TypeScript points at children, size, kind, RunConfirm, ConfirmBody, FormBody, RenameBody, useCloseWhileOpen and each import from @gopherium/godmin/dialogs. The rest changes what the reader sees and when onClose runs.

godmin 0.28.0 draws toasts as WordPress’s new admin draws its snackbars. Change your code in these places:

  • useToaster().name and the nameLength prop of Toaster are gone. Put the name in the message as it is. A long name wraps.
  • dismissAfter now times only a toast with no action. Pass actionDismissAfter to time a toast with an action. It stays 10 seconds when you pass nothing.
  • A toast with an action has no close button. A click anywhere on it clears it, so a test that pressed the close button clicks the toast instead. A stylesheet that styles .godmin-toast__dismiss styles nothing now.
  • dismissLabel is now only the hint of a toast with no action, and its default is Dismiss this notice, WordPress’s words. A test that reads the old hint, Dismiss, reads the new one.
  • A toast now sits in a .godmin-toasts__item element inside .godmin-toasts. A selector such as .godmin-toasts > .godmin-toast, or code that reads the children of the region as toasts, reaches the toast through that element.
  • A toast now rises into place as it arrives, as Motion shows. A browser test that measures where a toast sits waits for that motion to end, or runs with a reduced motion preference.

TypeScript points at each call to name and at nameLength. The rest changes only what the reader sees.

godmin 0.25.0 gives the sidebar parts the names WordPress gives them. TypeScript points at each old name, and the changelog lists every new one. Change your code in these places too:

  • Install @wordpress/i18n next to godmin, and take @tanstack/react-router 1.170.44 or a newer 1.x release.
  • NavigationScreen draws its title as an h1 and no longer moves the focus to it. Pass headingLevel={2} to every Page beside it, as heading levels explains.
  • The sidebar and the drawer have no padding of their own. A sidebar screen pads its rows.
  • A stylesheet that reads the sidebar width reads --godmin-nav-sidebar-width.
  • A stylesheet that styles the sidebar slot or a sidebar screen reads .godmin-layout__sidebar and the .godmin-navigation-screen classes.
  • The phone menu button is named “Open navigation panel” by default. A test that finds it by its old name, “Open navigation”, finds it by the new one.
  • PageTabs draws its tabs as a ul list, one li per tab, and its .godmin-page-tabs class sits on that list. A stylesheet that styles the tabs by the nav reads the list.
  • useUnsavedText and markLatest came in 0.24.1 and come back in 0.27.0. 0.25.0 and 0.26.0 do not have them, so an app that uses them on 0.24.1 moves straight to 0.27.0 or later.

godmin 0.23.0 shows every failed write in a toast, never inside a dialog or above the list, as WordPress does. Take 0.23.1 or later, which lets a dialog take a write’s promise whether the write succeeds or fails. Change your code in these places:

  • ConfirmDialog’s onConfirm no longer answers a failure to show. To close the dialog at once, make it a plain function that returns nothing, and drop the async your old handler needed. An async function always returns a promise. Return the write’s promise to keep the dialog busy until the write ends. Escape, a click outside it and its close button now close it even while it works.
  • ConfirmBody and RenameBody no longer take failure, and RenameBody no longer takes busy. Close a rename when the reader presses Save, then write. RenameBody also sends a name left as it was, and stops only a blank one.
  • useListRun no longer answers failure, so drop the notice you showed above the list. The function that run.onStart() answers now takes only whether a row moved.
  • useBulkRun toasts your failed words when a row failed, in place of the done words.

TypeScript points at each prop and field that went away, at an onConfirm that answers a failure and at a run settled with a failure. The rest changes only what the reader sees. In each case, show the failure in a toast, as a failure from a dialog shows.

startListDates and listDate left the main entry. Import them from @gopherium/godmin/dates:

import { listDate, startListDates } from '@gopherium/godmin/dates'

Keep @wordpress/date and @wordpress/i18n installed next to godmin while you use them.

godmin 0.7.0 and older asked you to copy a patch for @wordpress/element. Newer releases support design system versions that bring @wordpress/element 8.7.0 or newer, which needs no patch.

Delete the patch file, its patchedDependencies entry and any build step that copies it. If your package.json lists @wordpress/element, move it to 8.7.0 too. A leftover entry makes pnpm install stop with ERR_PNPM_UNUSED_PATCH.

godmin is Apache-2.0. The design system packages are GPL-2.0-or-later and are peer dependencies: your application installs them, godmin never redistributes them. Your built bundle combines both and is conveyed under the WordPress packages’ terms.