async-transforms
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -59,7 +59,12 @@ import worker from 'worker_threads'; | ||
} else if (activeWorkers < options.tasks) { | ||
// In commonJS mode, we have to _again_ require the script, as the Worker ctor incorrectly | ||
// only allows ".js" (run as modules because of `type: module`) or ".mjs" extensions. | ||
// This will probably be fixed in a future Node. Sounds like a bug. | ||
const code = isModule ? workerTarget : `require(${JSON.stringify(workerTarget)});`; | ||
w = new worker.Worker(code, {workerData: {dep}, eval: !isModule}); | ||
if (isModule) { | ||
w = new worker.Worker(workerTarget, {workerData: {dep}}); | ||
} else { | ||
// In commonJS mode, we have to _again_ require the script, as the Worker ctor incorrectly | ||
// only allows ".js" (which attempts to run as a /module/, because of `type: module`) or | ||
// ".mjs" extensions (which is always a module). | ||
// This will probably be fixed in a future Node. Sounds like a bug. | ||
const code = `require(${JSON.stringify(workerTarget)});`; | ||
w = new worker.Worker(code, {workerData: {dep}, eval: true}); | ||
} | ||
++activeWorkers; | ||
@@ -66,0 +71,0 @@ } else { |
{ | ||
"name": "async-transforms", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Asynchronous stream transforms", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
36115
633