From 6dade61ac4d5e08f503812e13f8b77f2d8d992de Mon Sep 17 00:00:00 2001 From: skywalker Date: Thu, 23 Dec 2021 02:17:19 +0000 Subject: [PATCH 1/2] fix: buildDependencies lost after build failure --- src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.ts b/src/index.ts index 40485a81..97da2612 100644 --- a/src/index.ts +++ b/src/index.ts @@ -187,6 +187,7 @@ export async function build(_options: Options) { const buildAll = async () => { const killPromise = killPreviousProcess() + const preBuildDependencies = new Set(buildDependencies) buildDependencies.clear() if (options.clean) { @@ -217,6 +218,9 @@ export async function build(_options: Options) { css: index === 0 || options.injectStyle ? css : undefined, logger, buildDependencies, + }).catch((error) => { + preBuildDependencies.forEach(buildDependencies.add) + throw error }) }), ]) From 6526dc8eee90a6dd91b81661c0501e9139e70a91 Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Sat, 25 Dec 2021 12:22:21 +0800 Subject: [PATCH 2/2] tweaks --- src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 97da2612..d7c09872 100644 --- a/src/index.ts +++ b/src/index.ts @@ -187,7 +187,9 @@ export async function build(_options: Options) { const buildAll = async () => { const killPromise = killPreviousProcess() - const preBuildDependencies = new Set(buildDependencies) + // Store previous build dependencies in case the build failed + // So we can restore it + const previousBuildDependencies = new Set(buildDependencies) buildDependencies.clear() if (options.clean) { @@ -219,7 +221,7 @@ export async function build(_options: Options) { logger, buildDependencies, }).catch((error) => { - preBuildDependencies.forEach(buildDependencies.add) + previousBuildDependencies.forEach(v => buildDependencies.add(v)) throw error }) }),