workerpool: Cannot use import statement outside a module (in Vite)
When I use:
import workerUrl from "@/workers/carData?worker&url";
in Vite, which seems like workerpool doesn’t give an option to handle module script, like below.
It might be possible to expose worker construct options to workerpool.pool function.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 16 (5 by maintainers)
Yeah, this is just what I mean but these days I’ve been so busy that I hadn’t read the source code of workerpool yet. It is supposed to be fixed otherwise this issue is likely to be more common as this kind of tool such as Vite is going popular.
@josdejong It might not be a transpiling issue. When I turned to use web worker directly and set worker type to module, it works well.
The result shows successfully with no importing error:
Transpiled worker code as follows: