Is it possible to use worker + WASM in a library that targets both browsers and node? This repo is a proof of concept of how that could be done.
This work is built on top of the method proposed in this article and uses comlink to bridge the gap between node's worker-threads and web-workers.
First, make sure to install emscripten and then build the project:
npm install
npm run build
Once that is done, you can run the project in either Node or the Browser:
- Node:
npm run start:node
- Web:
npm run start:web
and navigate to http://127.0.0.1:8080/examples/