Problem when using mediapipes from inside a worker loaded as a module #5257
Labels
platform:javascript
MediaPipe Javascript issues
task:image classification
Issues related to Image Classification: Identify content in images and video
type:support
General questions
Have I written custom code (as opposed to using a stock example script provided in MediaPipe)
None
OS Platform and Distribution
Web
MediaPipe Tasks SDK version
master branch
Task name (e.g. Image classification, Gesture recognition etc.)
Image classification but should apply to all tasks
Programming Language and version (e.g. C++, Python, Java)
Javascript
Describe the actual behavior
When loading the code I get an importScript exception
Describe the expected behaviour
That it also works from workers loaded as module
Standalone code/steps you may have used to try to get what you need
If your worker is loaded as a worker, e.g.:
You will get an error saying that importScripts is not supported.
Note, as framework with bundlers such as vite, convert you commonJS module to ESM module, converting the worker to commonJS is not an option.
However, I had terrible luck, as the typescript compiler in the project transpiles everything to commonJS and replaces the
import
withresolve,
which is a dead end. (At least after a few hours, I did not find a suitable workaround.)What is the reason for compiling with TypeScript to CommonJS and converting it via rollup to an ES module, anyway?
So, I am here asking for help or guidance on proceeding. Changing the overall compiling workflow and supplying a patch without asking would be a bad style.
The text was updated successfully, but these errors were encountered: