Skip to content

feat(core): improve module trace formatting in error messages - #6290

Merged
chenjiahan merged 2 commits into
mainfrom
module_traces_0930
Sep 30, 2025
Merged

feat(core): improve module trace formatting in error messages#6290
chenjiahan merged 2 commits into
mainfrom
module_traces_0930

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

Refactor module trace formatting to show clearer import paths.

image

Before

  @ ./src/child2.js
  @ ./src/child1.js
  @ ./src/index.js

After

Import traces (entry → error):
  ./src/index.js
  ./src/child1.js
  ./src/child2.js
  ./src/child3.js ×

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings September 30, 2025 06:54
@netlify

netlify Bot commented Sep 30, 2025

Copy link
Copy Markdown

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 525009d
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/68db810112a9d20008bbc1d6
😎 Deploy Preview https://deploy-preview-6290--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 46 (🔴 down 23 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 resolveModuleTrace function with a new formatModuleTrace function 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.

Comment on lines +62 to +66
moduleNames.unshift(`${errorFile} ${color.bold(color.red('×'))}`);
}

const rawTrace = moduleNames
.reverse()

Copilot AI Sep 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread packages/core/src/helpers/format.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

test('should log error module trace', async ({ build }) => {
const rsbuild = await build({
catchBuildError: true,
});
expect(rsbuild.buildError).toBeTruthy();
await rsbuild.expectLog('@ ./src/index.tsx');

[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

@chenjiahan
chenjiahan merged commit 209718f into main Sep 30, 2025
11 checks passed
@chenjiahan
chenjiahan deleted the module_traces_0930 branch September 30, 2025 07:13
@chenjiahan chenjiahan mentioned this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants