Stay up to date on releases
Create your free account today to subscribe to this repository for notifications about new releases, and build software alongside 40 million developers on GitHub.
Sign up for free See pricing for teams and enterprisescomlink-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.js | index.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.