Import Web Worker as ?url #5690
Replies: 7 comments
-
I second this, im having the same issue and it looks like the vite dev build is injecting the following 3 imports into a classic worker that doesnt have support for imports: ` import vitePluginRequire_1669650957052_5135 from "/@id/__vite-browser-external:fs"; This is happening when trying to create a web worker to run with WASM multithreaded. Please advise on a workaround. |
Beta Was this translation helpful? Give feedback.
-
Also encountered that problem. Lol |
Beta Was this translation helpful? Give feedback.
-
are there any workaround to this? |
Beta Was this translation helpful? Give feedback.
-
Can anyone fix this? I'm also facing the same issue after upgrading to angular 18. |
Beta Was this translation helpful? Give feedback.
-
I use another vite config for building the worker and conditional url for worker in DEV & PROD |
Beta Was this translation helpful? Give feedback.
-
Were you able to fix this issue? I'm facing the same issue after migrating to angular 18 |
Beta Was this translation helpful? Give feedback.
-
Facing the same problem using vite with module federation. package.json vite.config.ts // https://vitejs.dev/config/ |
Beta Was this translation helpful? Give feedback.
-
Hi,
I need to get web worker file path instead of using
?worker
because I won't initialize it manually, I need to pass it to emscripten'slocateFile
.When I try to do this I get
Uncaught SyntaxError: Cannot use import statement outside a module
because vite is appendingimport { injectQuery as __vite__injectQuery } from "/@vite/client";
at the beginning of my worker file. I've tried importing using?url
,new URL()
, I've tried adding it tooptimizeDeps.exclude
. Nothing seems to help, vite is always appendinginjectQuery
.I can't modify my worker file because it's output file from emscripten (it's generated automatically during build)
Is there any way around it?
Thanks,
Bartosz
Beta Was this translation helpful? Give feedback.
All reactions