Open robbiemu opened 3 years ago
modifying ts-worker like this allows the later solution to work (or equivalently, with "path"):
function getWorkerFilePath(workerFilename) {
var callerFilePath = stack[stack.length - 2].getFileName();
var res = callerFilePath.slice(0, callerFilePath.lastIndexOf('/'));
return workerFilename.startsWith('/')
? workerFilename
: res.concat('/' + workerFilename);
}
suggestion: if the current behavior really is valuable, consider allowing workerFilename to be a string or an array of strings. If it is an array of strings, it can process them with path.join
.
I'm almost ready with that, and maybe I will find there is a solution for this already, but it gives me the error
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
diagnosticText: "src/blockchain/utilities.ts(117,95): error TS2304: Cannot find name 'UUID'.\n",
diagnosticCodes: [ 2304 ]
})
UUID
is defined globally in global.d.ts: type UUID = number | string
Requested support from ts-node for this issue: https://github.com/TypeStrong/ts-node/discussions/1260
I am getting the error:
The directory structure I am working in is like: src/blockchain/
so, the worker is in the same directory as the utilities library where it is being referenced.
I have the worker:
get-block-at-difficulty.worker.ts
and it is relying on utilities.ts where it is also being called. see this excerpt:
utilities.ts
I have a jest test for this:
utilties.spec.ts
I thought to try specifying the absolute path:
but this produces basically the same error: