PortBlueSky / thread-puddle

A library to pool Node.js worker threads, automatically exposing exported module methods using Proxy Objects. :rocket:
15 stars 3 forks source link

Make ts-node dependency optional #6

Closed spmiller closed 3 years ago

spmiller commented 3 years ago

Hi there,

Thanks for your work on this library! We have begun using it and it makes creating tasks for worker threads much easier.

One thing we have noticed is that with the 0.3.0 release, the typescript package is required at runtime. This is because ts-bridge.ts tries to load ts-node, and it doesn't seem to cater for the case where the typescript package is not there.

Although we use TypeScript for our project, we compile to JS at runtime, and we get errors like this:

2021-03-16 02:35:31+0000:     at Timeout._onTimeout (/opt/app/node_modules/thread-puddle/lib/index.js:225:20)
2021-03-16 02:35:31+0000:     at listOnTimeout (internal/timers.js:549:17)
2021-03-16 02:35:31+0000:     at processTimers (internal/timers.js:492:7)

Assuming this isn't just user error, I am hoping to make ts-node an optional peer dependency, and somehow only include ts-node if it is available. If it is user error, I would appreciate being pointed in the right direction!

If work is required, I would be happy to have a go at a PR.

Thanks!