I'm spinning up some node workers and need each worker to pull code from a path expressed in tsconfig's paths compiler options. How do you configure worker to acknowledge paths from tsconfig?
here's how I create a Worker:
const workerTs = (ordinalPosition: number, file: string, workerOptions: WorkerOptions): Worker =>
{
workerOptions.eval = true;
if (!workerOptions.workerData)
{
workerOptions.workerData = {};
}
workerOptions.workerData.__filename = file;
workerOptions.workerData.blsSalaryArray = blsSalaryArray;
workerOptions.workerData.dataToProcess = chunks[ ordinalPosition ];
return new Worker(`
const wk = require('worker_threads');
require('ts-node').register();
let file = wk.workerData.__filename;
delete wk.workerData.__filename;
require(file);`,
workerOptions
);
};
And here's the error I'm receiving:
{
diagnosticText: "... Cannot find module '@datastop-io/datastop-io-libraries' or its corresponding type declarations.\r\n",
diagnosticCodes: [ 2307 ]
}
Here's my paths configuration in tsconfig.base.json:
{
"compilerOptions":
{
"paths":
{
"@datastop-io/datastop-io-libraries":["libs/datastop-io-libraries/src/index.ts"]
}
}
}