feat(core): improve module trace formatting in error messages - #6290
Conversation
✅ 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 refactors module trace formatting in error messages to show clearer import paths. The changes transform the previous format showing trace paths with "@" symbols into a more readable format that shows the import chain from entry point to error location.
- Replaced the old
resolveModuleTracefunction with a newformatModuleTracefunction that provides clearer formatting - Modified trace display to show import paths in forward order (entry → error) instead of reverse order
- Added visual indicators including an "×" symbol to mark the error location
Reviewed Changes
Copilot reviewed 6 out of 10 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/core/src/helpers/format.ts | Core formatting logic refactored to improve module trace display |
| e2e/cases/diagnostic/import-traces/src/*.js | Test files added to verify import chain behavior |
| e2e/cases/diagnostic/import-traces/index.test.ts | End-to-end tests to validate the new trace formatting |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| moduleNames.unshift(`${errorFile} ${color.bold(color.red('×'))}`); | ||
| } | ||
|
|
||
| const rawTrace = moduleNames | ||
| .reverse() |
There was a problem hiding this comment.
The errorFile is being added to moduleNames with formatting, but this formatted string will be processed again in the reverse() and map() operations on lines 65-68. This could result in incorrect formatting or the error marker appearing in the wrong position in the final output.
There was a problem hiding this comment.
💡 Codex Review
rsbuild/e2e/cases/config/stats-module-trace/index.test.ts
Lines 3 to 9 in bd8900d
[P1] Update stats module trace test for new error format
The new formatter no longer emits lines prefixed with @ for module traces, yet e2e/cases/config/stats-module-trace/index.test.ts still asserts @ ./src/index.tsx. With the new output ("Import traces (entry → error): …"), this assertion will never match and the e2e suite will time out. The test should be adjusted to look for the new formatted trace instead of the removed @-style line.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting

Summary
Refactor module trace formatting to show clearer import paths.
Before
After
Checklist