Fix broken standalone npm install in pattern-creator & pattern-directory (#754)#755
Open
obenland wants to merge 3 commits into
Open
Fix broken standalone npm install in pattern-creator & pattern-directory (#754)#755obenland wants to merge 3 commits into
obenland wants to merge 3 commits into
Conversation
#746 bumped `@wordpress/scripts` to 32.3.0 (React 19 era) in every workspace and fully migrated the theme's runtime `@wordpress/*` dependencies to the matching generation, but left the two plugins' runtime dependencies on the old React-18 generation. Each plugin's `package.json` was therefore internally inconsistent — `scripts` required `react@^19` while `block-editor` et al. required `react@^18` — so a standalone `npm install` (as on the wordpress.org sandbox) failed with ERESOLVE (#754). Align both plugins' runtime `@wordpress/*` dependencies with the React-19 generation the theme already uses, and fix the fallout: - pattern-creator/pattern-directory `package.json`: bump runtime `@wordpress/*` deps to the React-19 generation (block-editor 15.20, components 34, element 7, …). All the `__experimental`/`__unstable` APIs the creator relies on still exist in these versions. - pattern-creator `webpack.config.js`: add a `fullySpecified: false` rule. The creator deliberately bundles `@wordpress/editor`, whose newer ESM build imports the CommonJS `diff` package via extensionless subpaths that webpack 5 otherwise refuses to resolve. - pattern-creator `jest.config.js`: map bare `@wordpress/*` imports to their built CommonJS entry. These packages ship a `react-native` field pointing at untranspiled `src`, which jsdom's `browser` export condition falls back to, making Jest execute raw ESM/TypeScript source and pull in untransformed deps. Also transpile the few ESM-only leaf dependencies (uuid, marked) that the built packages import. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MJAbX3ist1XFiqb78Cu2TN
There was a problem hiding this comment.
Pull request overview
This PR fixes standalone npm install failures in the two plugin workspaces by aligning their runtime @wordpress/* dependencies with the React 19 generation required by @wordpress/[email protected], and by adjusting the pattern-creator build/test tooling to handle newer ESM packaging.
Changes:
- Bump
@wordpress/*runtime dependencies inpattern-creatorandpattern-directoryto React 19–compatible versions to eliminateERESOLVEpeer conflicts during standalone installs. - Update
pattern-creator’s webpack config to relax “fully specified” ESM resolution so bundled@wordpress/*ESM can import certain CommonJS deps (e.g.diff) via extensionless subpaths. - Update
pattern-creator’s Jest config to map bare@wordpress/*imports to built CommonJS outputs and transpile a few ESM-only leaf deps used by those builds.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| public_html/wp-content/plugins/pattern-directory/package.json | Updates runtime @wordpress/* dependency versions to match the React 19 tooling baseline and allow standalone installs. |
| public_html/wp-content/plugins/pattern-creator/package.json | Updates runtime @wordpress/* dependency versions (plus related packages) to remove the React 18/19 peer mismatch in standalone installs. |
| public_html/wp-content/plugins/pattern-creator/webpack.config.js | Adds a webpack resolve rule for fullySpecified: false to accommodate newer ESM import patterns in bundled @wordpress/* packages. |
| public_html/wp-content/plugins/pattern-creator/jest.config.js | Maps @wordpress/* to built CJS entries and expands Jest transforms to handle ESM-only transitive deps during unit tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
|
@bor0 Could I ask for your review when you get a chance? |
The extensionless-subpath problem is confined to bundled @wordpress/* ESM under node_modules, so limit the `fullySpecified: false` relaxation to those files and keep strict ESM resolution for project source. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MJAbX3ist1XFiqb78Cu2TN
Condense the explanatory comments added for the Jest module mapping and the webpack fullySpecified rule. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MJAbX3ist1XFiqb78Cu2TN
Member
|
Hi @obenland, thanks for this PR! On my sandbox, I get another error (even after wiping |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #754.
Problem
#746 bumped
@wordpress/scriptsto32.3.0(the React-19 generation) in every workspace and fully migrated the theme's runtime@wordpress/*dependencies to the matching generation — but left the two plugins' runtime dependencies on the old React-18 generation.Each plugin's
package.jsonwas therefore internally inconsistent:@wordpress/scriptsrequiredreact@^19while@wordpress/block-editorand friends requiredreact@^18. A standalonenpm installinside the plugin directory (which is how it's deployed on the wordpress.org sandbox) failed with a fatalERESOLVE:The monorepo root install papered over this via npm's workspace nesting, so it only surfaced standalone.
Fix
Complete the migration #746 started for the theme, and address the fallout:
package.json(both plugins) — bump runtime@wordpress/*dependencies to the React-19 generation the theme already uses (block-editor15.20,components34,element7, …). All the__experimental/__unstableAPIs the creator relies on were verified to still exist in these versions.webpack.config.js(creator) — add afullySpecified: falseresolve rule. The creator intentionally bundles@wordpress/editor(it isn't registered on the front end), and editor's newer ESM build imports the CommonJSdiffpackage via extensionless subpaths that webpack 5 otherwise refuses to resolve.jest.config.js(creator) — map bare@wordpress/*imports to their built CommonJS entry. These packages ship areact-nativefield pointing at untranspiledsrc, which jsdom'sbrowserexport condition falls back to, causing Jest to execute raw ESM/TypeScript source and drag in untransformed dependencies. Also transpile the few ESM-only leaf deps (uuid,marked) the built packages import.Verification
npm installnow completes for both plugins (no fatal ERESOLVE)npm installsucceedsnpm run buildsucceeds for bothpattern-creatorandpattern-directorynpm run test:unit --workspace=wporg-pattern-creator— 37/37 tests pass (matches trunk)npm run lint:jspasses for both workspacesThe remaining
npm warn ERESOLVE overriding peer dependencywarnings on the directory plugin are non-fatal: a transitively-resolved@wordpress/[email protected]declaresreact@^18(the WordPress packages reverted React 19 between 15.20 and 15.23), which npm auto-overrides. Installation completes successfully.🤖 Generated with Claude Code