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.
One copy of each shared package
Section titled “One copy of each shared package”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/themerenders components unthemed.@wordpress/i18nrenders English. One copy of the runtime explains why.@wordpress/dateleaves 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-authkeeps a configured transport that half the app cannot see.
The config handles this twice:
godminDedupemakes Vite resolve each listed package once.godminSingleCopy()fails the build, naming the package and both paths, if a duplicate got through anyway.
Paint sooner
Section titled “Paint sooner”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.
Lint your stylesheets
Section titled “Lint your stylesheets”@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.
Design system versions
Section titled “Design system versions”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.
Upgrading from godmin 0.31.0
Section titled “Upgrading from godmin 0.31.0”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/dialogsis gone. ImportConfirmDialog,FormDialog,DialogAnswerand their props types from@gopherium/godmin. godmin no longer has@wordpress/componentsas a peer. An app that draws DataViews keeps it, since DataViews needs it.ConfirmDialogtakes the question astitleand what will happen asdescription, in place ofchildren.sizeis gone, since a confirm has one width and is a card at every width. Passintent="irreversible"for an action that cannot be undone, which draws its button red.RunConfirm,ConfirmBody,RunConfirmPropsandConfirmBodyPropsare gone. Give the list action acallbackthat stores the rows, drop itsRenderModal,hideModalHeaderandmodalFocusOnMount, and render aConfirmDialogfrom your screen whoseonConfirmreturns the run, as running an action over the picked rows shows.FormBody,FormKind,RenameBody,useCloseWhileOpen,FormBodyPropsandRenameBodyPropsare gone. Give the row action acallbackthat stores the rows, drop itsRenderModal,modalHeader,modalSizeandmodalFocusOnMount, and render aFormDialogor aRenameDialogfrom your screen whoseonSubmitreturns the write ofuseDialogRun, 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 roledialogfinds it byalertdialog. - A confirm has no close button now, even with a
title. A test that pressed its close button presses Cancel instead. onCloseruns once the card has left the page, not at the press. A test that reads the dialog gone, oronClosecalled, right after a press waits for it, such as withwaitFor.- 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
onConfirmand 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
errorholds words, or whosecloseisfalse, now keeps the confirm open. Turn such an answer into one that closes when your app wants it to close. - Any object with a
thenmethod now counts as a promise, so the confirm waits for it. Before, it waited only for a realPromiseand closed at once for anything else. - A stylesheet that styles
.godmin-modal-body, its--copyand--createforms, or.godmin-modal-body__questionstyles nothing now. FormDialoghas nokindand nosize. It has one width, it is a card at every width, and its footer sets the space above its buttons.FormDialogcloses itself. Return nothing fromonSubmitto close at once, or the write’s promise to close when it ends, and stop closing it from your handler. Take it away inonClose, which runs once the card has left the page.- A form write that fails shows inside the dialog. Answer
{ error }with words fromonSubmit, 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.
Upgrading from godmin 0.27.0
Section titled “Upgrading from godmin 0.27.0”godmin 0.28.0 draws toasts as WordPress’s new admin draws its snackbars. Change your code in these places:
useToaster().nameand thenameLengthprop ofToasterare gone. Put the name in the message as it is. A long name wraps.dismissAfternow times only a toast with no action. PassactionDismissAfterto 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__dismissstyles nothing now. dismissLabelis now only the hint of a toast with no action, and its default isDismiss 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__itemelement 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.
Upgrading from godmin 0.24.0
Section titled “Upgrading from godmin 0.24.0”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/i18nnext to godmin, and take@tanstack/react-router1.170.44 or a newer 1.x release. NavigationScreendraws its title as anh1and no longer moves the focus to it. PassheadingLevel={2}to everyPagebeside 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__sidebarand the.godmin-navigation-screenclasses. - 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.
PageTabsdraws its tabs as aullist, oneliper tab, and its.godmin-page-tabsclass sits on that list. A stylesheet that styles the tabs by thenavreads the list.useUnsavedTextandmarkLatestcame 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.
Upgrading from godmin 0.22.0
Section titled “Upgrading from godmin 0.22.0”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’sonConfirmno longer answers a failure to show. To close the dialog at once, make it a plain function that returns nothing, and drop theasyncyour old handler needed. Anasyncfunction 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.ConfirmBodyandRenameBodyno longer takefailure, andRenameBodyno longer takesbusy. Close a rename when the reader presses Save, then write.RenameBodyalso sends a name left as it was, and stops only a blank one.useListRunno longer answersfailure, so drop the notice you showed above the list. The function thatrun.onStart()answers now takes only whether a row moved.useBulkRuntoasts yourfailedwords when a row failed, in place of thedonewords.
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.
Upgrading from godmin 0.19.0
Section titled “Upgrading from godmin 0.19.0”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.
Upgrading from godmin 0.7.0
Section titled “Upgrading from godmin 0.7.0”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.
License
Section titled “License”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.