feat(diagnostic): improve error formatting for data-uri imports#6677
feat(diagnostic): improve error formatting for data-uri imports#6677chenjiahan merged 2 commits intomainfrom
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 formatting for data-uri virtual module imports by providing clearer, more concise error messages. When imports fail in data-uri modules, the error messages now display a user-friendly label "data-uri virtual module" along with a truncated snippet of the content (limited to 30 characters) instead of showing the full data-uri which can be extremely long.
Key Changes:
- Added data-uri detection and formatting logic in the error formatter
- Implemented snippet truncation (30 character limit with ellipsis)
- Added comprehensive e2e tests for both dev and build modes
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/src/helpers/format.ts | Adds data-uri detection and formatting logic with snippet truncation to improve error message readability |
| e2e/cases/diagnostic/data-uri-import-error/src/index.js | Test fixture that imports a non-existent module via data-uri to trigger an error |
| e2e/cases/diagnostic/data-uri-import-error/index.test.ts | E2e tests verifying proper error formatting in both dev and build modes |
💡 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
Add support for displaying formatted error messages when imports fail in data-uri virtual modules.
This includes truncating long snippets and clearly indicating the source as a data-uri module. Also add e2e tests to verify the behavior in both dev and build modes.
Before
After
Checklist