astagi / workerloader-jest-transformer

🃏 Jest transformer for Webpack worker-loader
MIT License
15 stars 3 forks source link

Worker usage via comlink fails on "MessageChannel is not defined" #11

Open gthb opened 3 years ago

gthb commented 3 years ago

I'm using comlink to abstract communications with my worker. When I try out workerloader-jest-transformer, comlink.proxy borks trying to create a MessageChannel:

      at Object.serialize (node_modules/comlink/src/comlink.ts:219:30)
      at toWireValue (node_modules/comlink/src/comlink.ts:498:56)
          at Array.map (<anonymous>)
      at processArguments (node_modules/comlink/src/comlink.ts:468:34)
      at Object.subscribe [as apply] (node_modules/comlink/src/comlink.ts:435:45)
      at ...

... i.e. here: https://github.com/GoogleChromeLabs/comlink/blob/46f79fc257261b68f8987c5e6b9bd635589758df/src/comlink.ts#L219

Presumably MessageChannel needs to be mocked as well?

astagi commented 3 years ago

Hi @gthb can you please share your code or a sample that uses MessageChannel and workerloader-jest-transformer to reproduce your problem?

gthb commented 2 years ago

Hi @astagi, I'm sorry, I'm probably not going to put time into that, as I am not really using workerloader-jest-transformer, I just tried it out briefly in my worker prototype, and wanted to let you know about the snag I hit.