vlcn-io / vite-starter

scaffold for a vitejs based vlcn project
32 stars 6 forks source link

work around vite import url problems #9

Closed tantaman closed 1 year ago

tantaman commented 1 year ago

Vite has some inconsistencies when dealing with importing workers in prod vs dev mode.

Then more problems if those workers attempt to import wasm.

https://github.com/vitejs/vite/issues/13314

  1. using new URL('worker.js', import.meta.url) works in prod but not dev
  2. using import workerUri from 'worker?url work in dev but not prod
  3. using new URL('thing.wasm', import.meta.url) to import wasm from inside a worker does not work in dev or prod, we must instead pass the wasm uri down from the calling application where it is imported via import wasmUri from 'wasm?url'
tantaman commented 1 year ago

fml.