Views: Add React to the package's dev dependencies - #81139
Merged
Conversation
Views package tests fail in isolated mode due to the absence of React packages. See CI run 30882068183
manzoorwanijk
requested review from
Mamaduka,
aduth,
ciampo,
jsnajdr,
oandregal and
tyxla
August 4, 2026 09:38
manzoorwanijk
marked this pull request as ready for review
August 4, 2026 09:39
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: -96 B (0%) Total Size: 7.81 MB 📦 View Changed
|
oandregal
approved these changes
Aug 4, 2026
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.
What?
Noticed in #80832 (comment)
Adds
reactandreact-domto the@wordpress/viewspackage'sdevDependencies.Why?
packages/views/src/test/use-view.tsxis JSX and pulls in@testing-library/react, so running the tests needsreact/jsx-runtimeandreact-domresolvable from within the package. Neither is declared, so the package relies on React being hoisted to the rootnode_modules.That holds with the default hoisted install, but breaks as soon as dependencies are isolated — the test suite fails to run with
Cannot find module 'react/jsx-runtime' from 'packages/views/src/test/use-view.tsx'(surfaced in #75814).How?
Declares both as
devDependencies, notpeerDependencies.packages/views/srcis entirely.tswith no React import — the shipped build never references React; hooks come in through@wordpress/element, which declares the React peer itself and propagates it to consumers. So React is a test-time need only, which is whatdevDependenciesexpresses. Same shape as@wordpress/private-apis.Testing Instructions
Both suites should pass.
Use of AI Tools
Claude Code assisted with the dependency analysis and PR description; changes reviewed and verified by me.