Skip to content

Views: Add React to the package's dev dependencies - #81139

Merged
manzoorwanijk merged 2 commits into
trunkfrom
fix/views-react-dev-deps
Aug 4, 2026
Merged

Views: Add React to the package's dev dependencies#81139
manzoorwanijk merged 2 commits into
trunkfrom
fix/views-react-dev-deps

Conversation

@manzoorwanijk

@manzoorwanijk manzoorwanijk commented Aug 4, 2026

Copy link
Copy Markdown
Member

What?

Noticed in #80832 (comment)

Adds react and react-dom to the @wordpress/views package's devDependencies.

Why?

packages/views/src/test/use-view.tsx is JSX and pulls in @testing-library/react, so running the tests needs react/jsx-runtime and react-dom resolvable from within the package. Neither is declared, so the package relies on React being hoisted to the root node_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, not peerDependencies. packages/views/src is entirely .ts with 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 what devDependencies expresses. Same shape as @wordpress/private-apis.

Testing Instructions

npm run test:unit packages/views

Both suites should pass.

Use of AI Tools

Claude Code assisted with the dependency analysis and PR description; changes reviewed and verified by me.

Views package tests fail in isolated mode due to the absence of React packages. See CI run 30882068183
@manzoorwanijk manzoorwanijk added the [Type] Code Quality Issues or PRs that relate to code quality label Aug 4, 2026
@manzoorwanijk
manzoorwanijk marked this pull request as ready for review August 4, 2026 09:39
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Size Change: -96 B (0%)

Total Size: 7.81 MB

📦 View Changed
Filename Size Change
build/styles/block-library/post-author-biography/style-rtl.css 96 B -19 B (-16.52%) 👏
build/styles/block-library/post-author-biography/style-rtl.min.css 86 B -17 B (-16.5%) 👏
build/styles/block-library/post-author-biography/style.css 96 B -19 B (-16.52%) 👏
build/styles/block-library/post-author-biography/style.min.css 86 B -17 B (-16.5%) 👏
build/styles/block-library/style-rtl.css 22.4 kB -7 B (-0.03%)
build/styles/block-library/style-rtl.min.css 18.9 kB -5 B (-0.03%)
build/styles/block-library/style.css 22.5 kB -7 B (-0.03%)
build/styles/block-library/style.min.css 18.9 kB -5 B (-0.03%)

compressed-size-action

@manzoorwanijk
manzoorwanijk enabled auto-merge (squash) August 4, 2026 10:01
@manzoorwanijk
manzoorwanijk merged commit 611f9b9 into trunk Aug 4, 2026
73 checks passed
@manzoorwanijk
manzoorwanijk deleted the fix/views-react-dev-deps branch August 4, 2026 10:12
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants