GoogleChromeLabs/comlink-loader

Usage question

jperasmus opened this issue · 2 comments

Excited to try out this webpack loader!

  • How does this loader compare to workerize-loader?
  • Does this loader require a JS class export or can any other function be exported and used?

I've tried both and here's my findings:

workerize-loader and comlink-loader achieve the same thing - putting code into a worker at compile time. A small difference is that workerize uses individual exported functions via __webpack_exports__, while comlink uses a class as a whole.

I chose workerize-loader over comlink-loader because:

  • Workerize's implementation is smaller and simpler.
  • Workerize is based on functions which is more flexible (doesn't require class export).
  • Workerize is ES3 (+Promise, which is easily polyfilled), while comlink requires ES6 (Proxy, Map, WeakSet, generator) and ES7 (async functions). This means less build config and smaller bundle size (doesn't require all the polyfill) if you must support some legacy devices (Android 4.4, iOS 9, iOS 10.1/10.2)

Hi @fnlctrl, thanks for your reply. I had similar findings and also ended up going with workerize-loader.