feat: improve error message filename formatting#6685
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR improves error message readability by shortening absolute file paths in error messages to use relative paths from the project root. The changes add a root parameter to formatting functions throughout the error handling pipeline, enabling paths like /Users/path/to/project/src/App.jsx to be displayed as ./src/App.jsx.
Key Changes:
- Modified
formatFileNameandformatStatsErrorto accept a root path parameter for path shortening - Updated
formatStatsto pass the root path when formatting errors and warnings - Modified error/warning handlers in
socketServer.tsandcreateCompiler.tsto provide the root path from context
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/core/src/helpers/format.ts |
Added root path parameter to formatting functions and implemented path shortening logic to replace absolute paths with relative paths |
packages/core/src/helpers/stats.ts |
Updated formatStats to accept and pass root path parameter to error/warning formatters |
packages/core/src/server/socketServer.ts |
Modified error and warning handlers to pass this.context.rootPath to formatStatsError |
packages/core/src/provider/createCompiler.ts |
Updated formatStats call to include options.context.rootPath parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Summary
Make error messages more readable by shortening absolute paths using the project root path. This change modifies the filename formatter to accept and utilize the root path for better path display in error messages.
Before
After
Checklist