From af62e8f9de039b132c964e004ace975cfaa669d6 Mon Sep 17 00:00:00 2001 From: Danny van Velzen Date: Mon, 16 Dec 2024 10:17:52 -0800 Subject: [PATCH] Fix build --- scripts/worker/transpile.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/worker/transpile.js b/scripts/worker/transpile.js index 79e8d5458..363329b2f 100644 --- a/scripts/worker/transpile.js +++ b/scripts/worker/transpile.js @@ -28,11 +28,14 @@ module.exports = async function transpile(data) { if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== "lib" && entry.name !== "tests" && entry.name !== "dist") { queue.push(fullPath); } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx"))) { - const dest = fullPath - .replace(/([/\\])src/, "$1lib") + // Only replace src to 'lib' in the project tree. + // The repo could be cloned in a folder with 'src' and we don't want to replace that with 'lib' + const targetRelativePath = path + .relative(target.cwd, fullPath) + .replace("src" + path.sep, "lib" + path.sep) .replace(".tsx", ".js") .replace(".ts", ".js"); - + const dest = path.join(target.cwd, targetRelativePath); const swcOutput = await swc.transformFile(fullPath, { ...swcOptions, sourceFileName: path.relative(path.dirname(dest), fullPath).replace(/\\/g, "/"),