feat: RollupLog compat of UNRESOLVED_IMPORT warning#3711
Merged
IWANABETHATGUY merged 4 commits intorolldown:mainfrom Feb 28, 2025
Merged
feat: RollupLog compat of UNRESOLVED_IMPORT warning#3711IWANABETHATGUY merged 4 commits intorolldown:mainfrom
RollupLog compat of UNRESOLVED_IMPORT warning#3711IWANABETHATGUY merged 4 commits intorolldown:mainfrom
Conversation
hyf0
approved these changes
Feb 28, 2025
hi-ogawa
commented
Feb 28, 2025
IWANABETHATGUY
approved these changes
Feb 28, 2025
13 tasks
graphite-app bot
pushed a commit
that referenced
this pull request
Dec 5, 2025
#7341) - [x] Understand the issue and existing code structure - [x] Build the project to verify current state - [x] Add fields (`id`, `exporter`, `loc`, `pos`) to `NativeError` struct in Rust - [x] Update `to_binding_error` function to populate new fields from `BuildDiagnostic` - [x] Update TypeScript error types to include new fields - [x] Create tests to verify error information is exposed correctly - [x] Run build and tests to verify changes - [x] Address code review feedback - [x] Use 1-based numbering for line and match editor conventions - [x] Convert loc and pos to UTF-16 based encoding - [x] Add test with UTF-16 multi-byte characters (emoji) - [x] Remove unused string_wizard dependency - [x] All tests passing <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[Feature Request]: expose error information on JS API error object</issue_title> > <issue_description>### What problem does this feature solve? > > When there is an error from API-based usage, e.g. a missing export: > > ```js > try { > const bundle = await rolldown({ > input: '...' > }) > const generated = await bundle.generate({ format: 'cjs' }) > } catch (e) { > console.log(e) // e doesn't expose anything useful > } > ``` > > The error message is printed to the console, but the caught error object doesn't contain the same information. `e.message` is `"Build failed"` and `e.code` is `"GenericFailure"` - which are not really helpful. > > ### What does the proposed API look like? > > `e.message` and `e.code` should contain more specific information.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > <comment_new><author>@hyf0</author><body> > I think this one is solved. Errors returned from rust or caught in Js would be displayed as it is. > > --- edited > > looks like there are much to be improved</body></comment_new> > <comment_new><author>@sapphi-red</author><body> > > looks like there are much to be improved > > Would you clarify this?</body></comment_new> > <comment_new><author>@hyf0</author><body> > > > looks like there are much to be improved > > > > Would you clarify this? > > I reopen it becuase of reqeust I saw in #2734. > > It seemed it was suggesting add more specific fields to the each individual error object.</body></comment_new> > <comment_new><author>@sapphi-red</author><body> > I see. Warnings support `id` and `exporter` property (#3711). > > I think we can close this issue once we support `id`, `exporter`, `loc`, `pos`. > > related code: https://github.com/rolldown/rolldown/blob/06f24c0bc72d8700fec4563a97aa730510d2023c/crates/rolldown_binding/src/types/error/native_error.rs#L4-L7 > > </body></comment_new> > </comments> > </details> - Fixes #1956 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
There are quite a few extra properties https://rollupjs.org/configuration-options/#onlog. For now, I added a compatible properties only for
UNRESOLVED_IMPORTsince this one is used by Vite.I also changed from
#[napi]to#[napi(object)], so it won't wrapped as class and object properties are visible fromconsole.log(log).