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

Working with typescript causing an error: The worker script extension must be \".js\", \".mjs\", or \".cjs\". Received \".ts\" #345

Closed PrabhuPuredla95 closed 2 years ago

PrabhuPuredla95 commented 2 years ago

var workerpool = require('workerpool') var pool = workerpool.pool(__dirname + '/../workers/bulk_operations.ts') //causing the error

I have installed this module as well: https://www.npmjs.com/package/@types/workerpool

PrabhuPuredla95 commented 2 years ago

Node version: v14.19.0 typescript: v4.4.3

Early response would be highly appreciated

josdejong commented 2 years ago

You'll first need to create a bundle of your bulk_operations.ts file, and then load that bundle as worker.

See also #189

PrabhuPuredla95 commented 2 years ago

Thank you. Will try and let you know