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 optional #7

Closed spmiller closed 2 years ago

spmiller commented 3 years ago

In ts-bridge, try to resolve the library first. If require.resolve throws an error, then ts-node is not available. This has no effect for JavaScript applications but means TypeScript projects will need to ensure they have ts-node and typescript installed.

In package.json, make ts-node an optional peer dependency.

This fixes runtime errors in JavaScript applications like this:

2021-03-16 02:35:31+0000: Error: Worker 1 initialization timed out 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)

Fixes #6.