josdejong / workerpool

Offload tasks to a pool of workers on node.js and in the browser
Apache License 2.0
2.06k stars 147 forks source link

How to use with typescript #379

Closed SwapnilSoni1999 closed 10 months ago

josdejong commented 1 year ago

You can use @types/workerpool

https://www.npmjs.com/package/@types/workerpool

juanrmn commented 1 year ago

Just in case it helps someone else, to make it work with ts-node I had to add these workerThreadOpts:

const pool = workerpool.pool(
  path.join(__dirname, '/path/to/workerfile.ts'),
  {
    workerType: 'thread',
    workerThreadOpts: {
      execArgv: ['--require', 'ts-node/register', '-r', 'tsconfig-paths/register']
    }
  }
)