Skip to content

Comments

feat: RollupLog compat of UNRESOLVED_IMPORT warning#3711

Merged
IWANABETHATGUY merged 4 commits intorolldown:mainfrom
hi-ogawa:fix-rollup-log-compat
Feb 28, 2025
Merged

feat: RollupLog compat of UNRESOLVED_IMPORT warning#3711
IWANABETHATGUY merged 4 commits intorolldown:mainfrom
hi-ogawa:fix-rollup-log-compat

Conversation

@hi-ogawa
Copy link
Collaborator

Description

There are quite a few extra properties https://rollupjs.org/configuration-options/#onlog. For now, I added a compatible properties only for UNRESOLVED_IMPORT since 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 from console.log(log).

@hi-ogawa hi-ogawa marked this pull request as ready for review February 28, 2025 10:20
@IWANABETHATGUY IWANABETHATGUY added this pull request to the merge queue Feb 28, 2025
Merged via the queue into rolldown:main with commit 94f05d4 Feb 28, 2025
20 checks passed
@hi-ogawa hi-ogawa deleted the fix-rollup-log-compat branch February 28, 2025 11:08
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.
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.

3 participants