diff --git a/lib/utils/typescript.js b/lib/utils/typescript.js index 5f9d0d417..3f75c07f9 100644 --- a/lib/utils/typescript.js +++ b/lib/utils/typescript.js @@ -385,7 +385,9 @@ const __dirname = __dirname_fn(__filename); ) // Write the transpiled file with updated imports - const tempFile = filePath.replace(/\.ts$/, '.temp.mjs') + // Use process.pid in the filename to avoid collisions when run-multiple forks + // several processes that all transpile the same .ts files concurrently. + const tempFile = filePath.replace(/\.ts$/, `.${process.pid}.temp.mjs`) fs.writeFileSync(tempFile, jsContent) transpiledFiles.set(filePath, tempFile) }