vite-plugin-comlink icon indicating copy to clipboard operation
vite-plugin-comlink copied to clipboard

Fails when using WASM-based libraries

Open AndrewJSchoen opened this issue 2 years ago • 2 comments

I am trying to use this plugin in a vite-based project, where I am running a worker that uses a wasm-based library. I can successfully use the library with standard imports into the project, but when I attempt to load the library within the web worker, it stalls, even if the library itself isn't used. I have created a sandbox that shows this behavior. A couple other notes:

  • In the worker.js file, the library is being imported. Commenting this out should allow the App.jsx to retrieve the result of the add function and display it (instead of null).
  • The other stuff in App.jsx just confirms that the wasm-based library is indeed functioning within the non-webworker environment.
  • I tried fiddling with the ordering of the various plugins, but couldn't get anything to work with that.

Is this something that is a limitation of the library, or could it be a configuration issue somewhere? Thanks!

AndrewJSchoen avatar Jan 27 '23 20:01 AndrewJSchoen

Thanks for reporting. Quick guess: is your lib running the wasm inside a webworker? Than it might be problematic.

Will digg into it later will take some time...

mathe42 avatar Jan 27 '23 23:01 mathe42

Thanks for the reply. It isn't running a webworker as far as I know, but I may be mistaken. The lib itself is generated through wasm-bindgen and wasm-pack using their bundler target (link). I inquired with them about any limitations this may have but so far haven't heard back.

AndrewJSchoen avatar Jan 30 '23 19:01 AndrewJSchoen

might be fixed with v5 please try it and if it doesn't work reopen this issue.

mathe42 avatar May 26 '24 12:05 mathe42