mathe42 / vite-plugin-comlink

Use WebWorkers in Vite with comlink!
MIT License
170 stars 18 forks source link

Using two relative paths will result in an error. #135

Closed baclt1580 closed 4 months ago

baclt1580 commented 6 months ago

The code is within /src/components/Test/Test.vue.

async function test() {
  const instance = new ComlinkWorker(new URL('../../common/worker/worker', import.meta.url))
  const result = await instance.add(2, 3)
  console.log(result)
}
test()

The translated code in English is:

wrap(
  new Worker(
    new URL('' + "/src/components/Test/common/worker/worker?worker_file&type=module", import.meta.url),
    {type: "module"}
  )
);

But actually, I intended to request the "common" folder under "/src".