workerize-loader with Parcel bundler
ezekielaquino opened this issue · 1 comments
ezekielaquino commented
Does anyone know how to get this to play along with parcel?
tried everything in the documentation, no dice– it always tries to resolve workerize-loader!
as a package. any tips to the right direction much appreciated :) thanks in advance!
developit commented
Parcel supports Worker natively:
// index.js
import Comlink from 'comlink';
const worker = Comlink.wrap(new Worker('./worker.js'));
worker.foo().then(console.log);
// worker.js
import Comlink from 'comlink';
async function foo() {
return 42;
}
Comlink.expose({ foo });
You can expose a whole module like this:
// worker.js
import Comlink from 'comlink';
import * as funcs from './my-worker-code';
Comlink.expose(funcs);