Comparing version
@@ -26,3 +26,3 @@ "use strict"; | ||
const rebasedScriptPath = callerPath ? path.join(path.dirname(callerPath), scriptPath) : scriptPath; | ||
return rebasedScriptPath.replace(/\.ts$/, ".js"); | ||
return rebasedScriptPath; | ||
} | ||
@@ -43,3 +43,13 @@ function resolveScriptPath(scriptPath) { | ||
constructor(scriptPath) { | ||
super(resolveScriptPath(scriptPath)); | ||
const resolvedScriptPath = resolveScriptPath(scriptPath); | ||
if (resolvedScriptPath.match(/\.tsx?$/)) { | ||
const content = ` | ||
require("ts-node/register/transpile-only"); | ||
require(${JSON.stringify(resolvedScriptPath)}); | ||
`; | ||
super(content, { eval: true }); | ||
} | ||
else { | ||
super(resolvedScriptPath); | ||
} | ||
this.mappedEventListeners = new WeakMap(); | ||
@@ -71,3 +81,12 @@ } | ||
: resolveScriptPath(scriptPath); | ||
super(resolvedScriptPath, [], { esm: true }); | ||
if (resolvedScriptPath.match(/\.tsx?$/)) { | ||
const content = ` | ||
require("ts-node/register/transpile-only"); | ||
require(${JSON.stringify(resolvedScriptPath)}); | ||
`; | ||
super(new Function(content), [], { esm: true }); | ||
} | ||
else { | ||
super(resolvedScriptPath, [], { esm: true }); | ||
} | ||
allWorkers.push(this); | ||
@@ -74,0 +93,0 @@ this.emitter = new events_1.default(); |
{ | ||
"name": "threads", | ||
"version": "1.0.0-beta.2", | ||
"version": "1.0.0-beta.2-ts-node-worker", | ||
"description": "Easy to use, yet powerful multi-threading library for node.js, web browsers and Electron", | ||
@@ -9,3 +9,2 @@ "main": "dist/index.js", | ||
"build": "tsc", | ||
"pretest": "babel --plugins @babel/plugin-transform-typescript --plugins @babel/plugin-transform-modules-commonjs ./test/workers -d ./test/workers -x .ts", | ||
"test": "run-s test:ava test:puppeteer:basic test:puppeteer:webpack", | ||
@@ -12,0 +11,0 @@ "test:ava": "cross-env TS_NODE_FILES=true ava", |
@@ -149,3 +149,3 @@ <h1 align="center">threads</h1> | ||
await Thread.terminate(sum) | ||
await Thread.terminate(add) | ||
} | ||
@@ -152,0 +152,0 @@ |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
76216
0.7%1651
1.16%3
50%