Skip to content

[Bug]: resolveNewUrlToAsset does not work with binary assets #7894

@valadaptive

Description

@valadaptive

Reproduction link or steps

https://github.com/valadaptive/rolldown-import-asset-bug

What is expected?

Rolldown should bundle binary assets referenced via new URL(..., import.meta.url), copying them to the output and rewriting the URLs.

What is actually happening?

It errors out if the assets are not pure text:

[UNLOADABLE_DEPENDENCY] Error: Could not load src/meow_blobcat.png
   ╭─[ src/entry.js:1:20 ]
   │
 1 │ const blobcatUrl = new URL('./meow_blobcat.png', import.meta.url);
   │                    ───────────────────────┬──────────────────────  
   │                                           ╰──────────────────────── stream did not contain valid UTF-8
───╯

This seems unnecessary, since all it's doing is copying the files. Why do we care if they're valid UTF-8? Vite handles this situation just fine.

System Info

System:
    OS: Linux 6.17 Fedora Linux 43 (Forty Three)
    CPU: (16) x64 AMD Ryzen 7 7700X 8-Core Processor
    Memory: 26.41 GB / 61.88 GB
    Container: Yes
    Shell: 5.3.0 - /bin/bash
  Binaries:
    Node: 24.9.0 - /home/va_erie/.nvm/versions/node/v24.9.0/bin/node
    Yarn: 3.8.7 - /home/va_erie/.nvm/versions/node/v24.9.0/bin/yarn
    npm: 11.6.0 - /home/va_erie/.nvm/versions/node/v24.9.0/bin/npm
    pnpm: 10.13.1 - /home/va_erie/.local/share/pnpm/pnpm
    bun: 1.2.19 - /home/va_erie/.bun/bin/bun
    Deno: 2.4.2 - /home/va_erie/.deno/bin/deno
  Browsers:
    Chrome: 143.0.7499.169
    Firefox: 146.0
    Firefox Developer Edition: 146.0
  npmPackages:
    rolldown: ^1.0.0-beta.60 => 1.0.0-beta.60

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions