fix(classic): initialize chart canvas browser env#5789
Conversation
- register the VChart browser rendering environment before the classic app boots to avoid missing createCanvas during dashboard chart initialization. - pin classic VisActor dependency resolution to prevent mixed VChart and VRender runtime versions.
WalkthroughAdds a new ChangesVChart Browser Environment Initialization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
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 `@web/classic/rsbuild.config.ts`:
- Around line 13-17: The Visactor alias setup is hard-coded to nested
node_modules paths, which can break in hoisted or deduped installs. Update the
rsbuild config near the visactorDir and reactVChartVisactorDir definitions to
resolve each package root from its package.json instead of assuming
`@visactor/react-vchart/node_modules/`@visactor exists. Keep the aliases in the
same config block, but use package-based resolution so the paths remain stable
across install layouts.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dedae02f-6c0a-4d09-aee9-fa8ab0756293
📒 Files selected for processing (3)
web/classic/rsbuild.config.tsweb/classic/src/index.jsxweb/classic/src/lib/vchart.js
| const visactorDir = path.resolve(__dirname, './node_modules/@visactor') | ||
| const reactVChartVisactorDir = path.resolve( | ||
| __dirname, | ||
| './node_modules/@visactor/react-vchart/node_modules/@visactor', | ||
| ) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Avoid hard-coding Visactor paths under node_modules. These aliases depend on @visactor/react-vchart/node_modules/@visactor existing exactly as written, which can break on hoisted or deduped installs. Resolve the package roots from their package.json files instead.
🤖 Prompt for 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.
In `@web/classic/rsbuild.config.ts` around lines 13 - 17, The Visactor alias setup
is hard-coded to nested node_modules paths, which can break in hoisted or
deduped installs. Update the rsbuild config near the visactorDir and
reactVChartVisactorDir definitions to resolve each package root from its
package.json instead of assuming `@visactor/react-vchart/node_modules/`@visactor
exists. Keep the aliases in the same config block, but use package-based
resolution so the paths remain stable across install layouts.
Important
📝 变更描述 / Description
修复 classic 前端打开
/console时 VChart/VRender 报createCanvas未定义的问题。变更在应用入口提前注册 VChart 的 browser 环境,并将 classic 的 VisActor 相关依赖解析固定到同一套运行时,避免@visactor/vchart与@visactor/vrender-*混用不同版本实例。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
git diff --cached --check通过web/classic:bun run build通过http://localhost:5174/console正常渲染,不再触发createCanvasErrorBoundarySummary by CodeRabbit