Skip to content

fix(browser-react): drop React 17 from peer deps#1240

Merged
fi3ework merged 1 commit into
mainfrom
chore/browser-react-drop-react-17
May 12, 2026
Merged

fix(browser-react): drop React 17 from peer deps#1240
fi3ework merged 1 commit into
mainfrom
chore/browser-react-drop-react-17

Conversation

@fi3ework

Copy link
Copy Markdown
Member

Summary

Background

@rstest/browser-react statically imports react-dom/client, which does not exist under React 17, so React 17 users hit a hard resolution error at install/build time. The peer dep range, README, and act() docs were still advertising React 17 as supported, which is misleading. This PR makes the supported range honest after deciding not to land #1239 (which added a separate React 17 entry).

Implementation

  • Narrow peer deps to ^18.0.0 || ^19.0.0 in packages/browser-react/package.json.
  • Update README compatibility section to React >= 18 and drop the stale React 17 fallback note from the act() docs.
  • Extend _act detection in src/act.ts to fall back to React.unstable_act, so React 18.0.0 – 18.3.0 (which only expose unstable_act) get a working act instead of a no-op.
  • Refresh AGENTS.md guidance with the precise version boundaries (verified against published react/cjs/*.js bundles): React.act was only stabilized in 18.3.1, and React 17 has neither act nor unstable_act.

User Impact

React 17 users now get a clear peer-dep warning at install time instead of a confusing react-dom/client resolution failure. React 18.0.0 – 18.3.0 users get correct act batching behavior instead of a silent no-op fallback. React 18.3.1+/19 users are unaffected.

Related Links

Validation

Local: `pnpm run lint` ✓, `pnpm --filter @rstest/browser-react typecheck` ✓, `pnpm --filter @rstest/browser-react build` ✓.

Skipped locally (pre-existing failures on `origin/main`, unrelated to this PR — verified by re-running with the working tree stashed):

  • `pnpm --filter @rstest/core typecheck`: `packages/core/src/core/plugins/basic.ts(136,19)` — `injectDynamicImportOrigin` not in `RawRstestPluginOptions`.
  • `pnpm run test`: 6 failures in `packages/core/tests/core/rsbuild.test.ts` (rspack config snapshot drift).
  • `pnpm --filter @rstest/browser build`: declaration-file generation failure (blocks e2e).

CI will run the full suite.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions

github-actions Bot commented May 12, 2026

Copy link
Copy Markdown

Rsdoctor Bundle Diff Analysis

Found 12 projects in monorepo, 1 project with changes.

📊 Quick Summary
Project Total Size Change
adapter-rsbuild 3.6 KB 0
adapter-rslib 24.6 KB 0
adapter-rspack 7.7 KB 0
browser 2.0 MB 0
browser-react 3.7 KB +22.0 B (0.6%)
browser-ui 803.5 KB 0
coverage-istanbul 9.6 KB 0
core/browser 970.2 KB 0
core/loaders 869.0 B 0
core/main 1.6 MB 0
vscode/extension 58.9 MB 0
vscode/worker 14.4 KB 0
📋 Detailed Reports (Click to expand)

📁 browser-react

Path: packages/browser-react/.rsdoctor/rsdoctor-data.json

📌 Baseline Commit: 5034f79d55 | PR: #1238

Metric Current Baseline Change
📊 Total Size 3.7 KB 3.7 KB +22.0 B (0.6%)
📄 JavaScript 3.7 KB 3.7 KB +22.0 B (0.6%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: browser-react Bundle Diff

Generated by Rsdoctor GitHub Action

React 17 is not actually supported: `@rstest/browser-react` statically
imports `react-dom/client`, which does not exist under React 17 and
fails to resolve at install/build time.

- Narrow peer deps to `^18.0.0 || ^19.0.0` so npm/pnpm warn React 17
  users at install time instead of failing later at runtime.
- Update README compatibility section and drop the stale React 17
  fallback note from the `act()` docs.
- Extend the `_act` detection to fall back to `React.unstable_act`,
  so React 18.0.0 – 18.3.0 (which only expose `unstable_act`) actually
  get a working `act` instead of a no-op.
@fi3ework fi3ework force-pushed the chore/browser-react-drop-react-17 branch from cabc8ec to cdee1f6 Compare May 12, 2026 03:25
@fi3ework fi3ework changed the title chore(browser-react): drop React 17 from peer deps fix(browser-react): drop React 17 from peer deps May 12, 2026
@fi3ework fi3ework enabled auto-merge (squash) May 12, 2026 03:28
@fi3ework fi3ework disabled auto-merge May 12, 2026 03:42
@fi3ework fi3ework enabled auto-merge (squash) May 12, 2026 03:42
@fi3ework fi3ework merged commit fbd8eca into main May 12, 2026
19 checks passed
@fi3ework fi3ework deleted the chore/browser-react-drop-react-17 branch May 12, 2026 04:33
@9aoy 9aoy mentioned this pull request May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant