From dfa19f51a2797f6905995c82fcb4e378c33ea1d7 Mon Sep 17 00:00:00 2001 From: Itrulia Date: Wed, 31 May 2023 17:45:34 +0200 Subject: [PATCH] fix(js): postProcessInlinedDependencies throwing error on movePackage (#16127) --- packages/js/src/utils/inline.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/js/src/utils/inline.ts b/packages/js/src/utils/inline.ts index 459bc9ee7f9a2..0094158aa111e 100644 --- a/packages/js/src/utils/inline.ts +++ b/packages/js/src/utils/inline.ts @@ -58,9 +58,11 @@ export function postProcessInlinedDependencies( } const parentDistPath = join(outputPath, parentOutputPath); + const markedForDeletion = new Set(); // move parentOutput movePackage(parentDistPath, outputPath); + markedForDeletion.add(parentDistPath); const inlinedDepsDestOutputRecord: Record = {}; // move inlined outputs @@ -80,6 +82,7 @@ export function postProcessInlinedDependencies( copySync(depOutputPath, destDepOutputPath, { overwrite: true }); } else { movePackage(depOutputPath, destDepOutputPath); + markedForDeletion.add(depOutputPath); } // TODO: hard-coded "src" @@ -88,6 +91,7 @@ export function postProcessInlinedDependencies( } } + markedForDeletion.forEach((path) => removeSync(path)); updateImports(outputPath, inlinedDepsDestOutputRecord); } @@ -262,7 +266,6 @@ function buildInlineGraphExternals( function movePackage(from: string, to: string) { if (from === to) return; copySync(from, to, { overwrite: true }); - removeSync(from); } function updateImports(