Conversation
The blank template's tsconfig.json sets "jsx": "react-jsx", which makes both `bun run file.tsx` and `tsc --noEmit` try to resolve react/jsx-runtime. Without react and @types/react installed, creating a .tsx file in a fresh `bun init -y` project fails with "Cannot find module 'react/jsx-runtime'" at runtime and TS7026/TS2875 under tsc. Treat react like the existing typescript peer dependency: add react to peerDependencies and @types/react to devDependencies when neither is present, skip under --minimal, and leave existing react setups alone. Fixes #5056
|
Warning Review limit reached
Next review available in: 16 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughChangesReact dependencies for
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/cli/init/init.test.ts`:
- Around line 303-315: Update the initializer subprocess test around Bun.spawn
to concurrently drain stdout and stderr while awaiting proc.exited, then assert
the combined subprocess result after the package manifest expectations. Ensure
the test fails when bun init exits unsuccessfully, while preserving the existing
dependency assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8926a5ee-0629-4250-ae9d-9e14122ffb6b
📒 Files selected for processing (3)
docs/quickstart.mdxsrc/runtime/cli/init_command.rstest/cli/init/init.test.ts
|
Updated 11:20 PM PT - Jul 31st, 2026
✅ @robobun, your commit 02f8e48368385ccfdb46d5ccea5044ecd8784a71 passed in 🧪 To try this PR locally: bunx bun-pr 36607That installs a local version of the PR into your bun-36607 --bun |
… react-free The Library template is publishable (private=false); declaring react as a peerDependency there would be a wrong consumer-facing contract.
There was a problem hiding this comment.
Both earlier findings are addressed — needs_react_dependency is now gated on Template::Blank so the Library template stays react-free, and the existing-react test drains its pipes and asserts exit. The code looks correct to me. Deferring to a maintainer only because making react + @types/react part of the default bun init -y scaffold is a user-facing default change worth a human sign-off.
What was reviewed:
needs_react_dependencygating:--minimal,TypescriptLibrary, React templates (early-return), and existing-react-in-any-dep-bucket all skip; onlyTemplate::Blankadds it.peerDependenciesblock still writestypescriptindependently whenneeds_react_dependencyis false.- New tests drain stdout/stderr concurrently;
--minimaltest now pinsdevDependenciesto exactly@types/bun.
Extended reasoning...
Overview
The PR adds react (peer) and @types/react (dev) to the bun init -y blank scaffold so a .tsx file resolves react/jsx-runtime out of the box, matching the tsconfig's existing "jsx": "react-jsx". Touches src/runtime/cli/init_command.rs (~40 lines), test/cli/init/init.test.ts (two new tests + snapshot updates + tightened --minimal assertions), and docs/quickstart.mdx.
Prior feedback
I previously flagged (1) the react gate leaking into Template::TypescriptLibrary (a publishable, non-private scaffold) and (2) an undrained-pipe subprocess test. Commit 02f8e48 gates on template == Template::Blank, and 768876c drains and asserts exit in the existing-react test. Both are resolved in the current diff.
Security risks
None. Scaffold-time dependency-list edits; no untrusted-input parsing, no auth/crypto/permissions.
Level of scrutiny
Code-wise this is low risk — it mirrors the existing needs_typescript_dependency pattern line-for-line, and the Template::Blank gate plus the three-bucket presence check keep it from clobbering existing setups or leaking into other templates. Tests cover blank, existing-react, and --minimal.
Why defer rather than approve
This changes what every bun init -y produces: react and @types/react are now installed by default in the blank template. That is a product/UX default (linked to #5056) rather than a pure bugfix, and per the approval guidelines a human should weigh in on user-facing default changes of this kind. No code concerns remain from my side.
What does this PR do?
Fixes #5056.
The blank
bun init -yscaffold writes atsconfig.jsonwith"jsx": "react-jsx", which makes bothbun run file.tsxandtsc --noEmittry to resolvereact/jsx-runtime. Because the scaffold did not installreactor@types/react, dropping a.tsxfile into a fresh project failed out of the box:This treats
reactthe same way the scaffold already treatstypescript: addreacttopeerDependenciesand@types/reacttodevDependencieswhen neither is present, skip under--minimal, and leave any existing react setup alone.After:
How did you verify your code works?
New tests in
test/cli/init/init.test.ts:bun init -y: a .tsx file runs and typechecks out of the boxrunsbun init -y, writes a.tsxfile, then assertsbun runsucceeds andtsc --noEmitexits 0bun init leaves an existing react dependency aloneasserts a pre-existingdependencies.reactis not moved or duplicated--minimaltest now assertspeerDependenciesis absent anddevDependenciesis exactly{ "@types/bun": "latest" }Existing snapshot tests updated for the new
package.jsonshape. All 17 tests in the file pass underbun bd test; the new.tsxtest fails underUSE_SYSTEM_BUN=1at the firsttoHaveProperty("react")assertion.no test proof · iteration 0 · Platform-specific test(s) that do not run on this machine. Deferring to CI, which covers all platforms: test/cli/init/init.test.ts