From 40951ecb4e3d9317a9da54d3ef2b55b23073a4a4 Mon Sep 17 00:00:00 2001 From: skywalker Date: Sat, 25 Dec 2021 12:24:45 +0800 Subject: [PATCH] fix: buildDependencies lost after build failure (#504) Co-authored-by: EGOIST <0x142857@gmail.com> --- src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 40485a81..d7c09872 100644 --- a/src/index.ts +++ b/src/index.ts @@ -187,6 +187,9 @@ export async function build(_options: Options) { const buildAll = async () => { const killPromise = killPreviousProcess() + // Store previous build dependencies in case the build failed + // So we can restore it + const previousBuildDependencies = new Set(buildDependencies) buildDependencies.clear() if (options.clean) { @@ -217,6 +220,9 @@ export async function build(_options: Options) { css: index === 0 || options.injectStyle ? css : undefined, logger, buildDependencies, + }).catch((error) => { + previousBuildDependencies.forEach(v => buildDependencies.add(v)) + throw error }) }), ])