Skip to content

Releases: GoogleChromeLabs/comlink-loader

2.0.0

14 Jan 19:55
Compare
Choose a tag to compare

comlink-loader version 2 changes the behavior of the singleton option, making it simpler than before and allowing TypeScript types work without any casting.

Now, importing a module using the comlink-loader?singleton! prefix immediately runs the module in a Web Worker and returns/reflects the module's exports:

worker.jsindex.js
export async function reverse (str) {
  return str.split('').reverse().join('');
}
import { reverse } from
  'comlink-loader?singleton!./worker';

await reverse('foo')  // "oof"

Note: seamless TypeScript support requires comlink-loader to be configured to apply to .worker.ts files in your Webpack configuration.

1.1.1

10 Jan 21:21
Compare
Choose a tag to compare
  • Filter options to avoid a worker-loader error when using ?singleton (thanks @jackyef!)
  • Fix support for Windows paths (thanks @nicolasmartinezv!)

1.1.0

04 Sep 13:52
Compare
Choose a tag to compare
  • Add new ?multi option to allow multiple instances of the worker:
import Foo from 'comlink-loader?multi!./foo.worker';

await new Foo()  // creates a new worker
await new Foo()  // creates another new worker

1.0.0

12 Jun 19:24
Compare
Choose a tag to compare

Initial release!