fix(js): postProcessInlinedDependencies throwing error on movePackage (#16127)

This commit is contained in:
Itrulia 2023-05-31 17:45:34 +02:00 committed by GitHub
parent 346c1f7e95
commit dfa19f51a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,9 +58,11 @@ export function postProcessInlinedDependencies(
} }
const parentDistPath = join(outputPath, parentOutputPath); const parentDistPath = join(outputPath, parentOutputPath);
const markedForDeletion = new Set<string>();
// move parentOutput // move parentOutput
movePackage(parentDistPath, outputPath); movePackage(parentDistPath, outputPath);
markedForDeletion.add(parentDistPath);
const inlinedDepsDestOutputRecord: Record<string, string> = {}; const inlinedDepsDestOutputRecord: Record<string, string> = {};
// move inlined outputs // move inlined outputs
@ -80,6 +82,7 @@ export function postProcessInlinedDependencies(
copySync(depOutputPath, destDepOutputPath, { overwrite: true }); copySync(depOutputPath, destDepOutputPath, { overwrite: true });
} else { } else {
movePackage(depOutputPath, destDepOutputPath); movePackage(depOutputPath, destDepOutputPath);
markedForDeletion.add(depOutputPath);
} }
// TODO: hard-coded "src" // TODO: hard-coded "src"
@ -88,6 +91,7 @@ export function postProcessInlinedDependencies(
} }
} }
markedForDeletion.forEach((path) => removeSync(path));
updateImports(outputPath, inlinedDepsDestOutputRecord); updateImports(outputPath, inlinedDepsDestOutputRecord);
} }
@ -262,7 +266,6 @@ function buildInlineGraphExternals(
function movePackage(from: string, to: string) { function movePackage(from: string, to: string) {
if (from === to) return; if (from === to) return;
copySync(from, to, { overwrite: true }); copySync(from, to, { overwrite: true });
removeSync(from);
} }
function updateImports( function updateImports(