fix: guard missing React version export - #810
Conversation
|
@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. Walkthrough本次变更为 ChangesReact version 缺失处理
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to The change prevents an import-time crash when React lacks a version export while preserving the existing behavior when the version is available. No actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
cc94637 to
3825a2b
Compare
Signed-off-by: 陳廷安 <73953029+nrps9909@users.noreply.github.com>
3825a2b to
a42c5a7
Compare
Summary
rc-util/es/refwhen a bundler's React interop object does not exposeversionversionis availableWhy
rc-util@5.44.4started readingversion.split(...)at module scope, and the same unguarded read remains in the current@rc-component/utilsource. In the Vite production-build cases reported in #647 and #783, the React named export can beundefined, so importingref.jsthrows before the application renders. Treating a missing version as an unknown version keeps the React 18-compatible path and prevents the module-load failure. A legacyrc-utilrelease would require a maintainer backport to5.x.Verification
Cannot read properties of undefined (reading 'split')atsrc/ref.tsnpm test -- --runInBand— 30 suites passed, 183 tests passed, 1 skippednpm run tscnpm run compile— ESM, CommonJS, and declarations built successfullynpx prettier --check src/ref.ts tests/ref-version.test.tsCloses #647 and #783.
AI assistance disclosure: Codex was used to trace the regression, construct the failing interop test, and draft the patch and PR description. The failure was reproduced against the unguarded source, and all listed verification was run locally on current
master.