Skip to content

Commit af62e8f

Browse files
committed
Fix build
1 parent cfe55db commit af62e8f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scripts/worker/transpile.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ module.exports = async function transpile(data) {
2828
if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== "lib" && entry.name !== "tests" && entry.name !== "dist") {
2929
queue.push(fullPath);
3030
} else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx"))) {
31-
const dest = fullPath
32-
.replace(/([/\\])src/, "$1lib")
31+
// Only replace src to 'lib' in the project tree.
32+
// The repo could be cloned in a folder with 'src' and we don't want to replace that with 'lib'
33+
const targetRelativePath = path
34+
.relative(target.cwd, fullPath)
35+
.replace("src" + path.sep, "lib" + path.sep)
3336
.replace(".tsx", ".js")
3437
.replace(".ts", ".js");
35-
38+
const dest = path.join(target.cwd, targetRelativePath);
3639
const swcOutput = await swc.transformFile(fullPath, {
3740
...swcOptions,
3841
sourceFileName: path.relative(path.dirname(dest), fullPath).replace(/\\/g, "/"),

0 commit comments

Comments
 (0)