worker-plugin
worker-plugin copied to clipboard
Error when using comlink
Hi, thanks for putting together this loader. Having an issue with integrating comlink.
main.ts
void async function() {
const worker = new Worker('./test.js', { type: 'module' })
const TestStore = Comlink.wrap(worker)
console.log(await new TestStore())
}()
test.js
import { expose } from 'comlink'
class Thing {
constructor() {
this.state = ''
}
setState(v) {
this.state = v
}
}
expose(Thing)
results in the error
Uncaught (in promise) TypeError: Cannot read property 'apply' of undefined
at MessagePort.eval
I am using the latest Chrome