Skip to content

[Bug]: new URL in a library gives file:/// address (Web Workers related) #989

@wfjsw

Description

@wfjsw

Version

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics         
    Memory: 1.35 GB / 27.86 GB
  Browsers:
    Edge: Chromium (131.0.2903.99)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @rsbuild/core: ^1.2.17 => 1.3.11 
    @rsbuild/plugin-babel: ^1.0.5 => 1.0.5 
    @rsbuild/plugin-react: ^1.1.1 => 1.3.0

Details

I have an Rslib powered library that can spawn a Web Worker: https://github.com/wudevstac/csv-js

The result bundle of that library seems to be pretty normal, where the worker file is separated and is referenced via import.meta.url:
https://github.com/wudevstac/csv-js/blob/91ca6586c0e4ea3cdf38ceeca098467d2f38db95/src/parserWorker.ts

However, once I try to call the function that spawns the worker in another Rsbuild powered React site, it turns out that the site is trying to load the worker via file:/// URL. Such URL does not exist in the original library artifact.

Image

Image

Image

Reproduce link

https://codesandbox.io/p/github/rspack-contrib/rsbuild-codesandbox-example/csb-hphzc5/draft/zealous-bush

Reproduce Steps

  1. Load the dev mode
  2. Upload a random CSV
  3. Check DevTools error log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions