From 5a074856011aefac0b4efb47bb77840f88b9e458 Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Sat, 2 Aug 2025 20:20:04 -0400 Subject: [PATCH] fix error conditions --- framework/hot.ts | 2 +- framework/marko.ts | 2 ++ framework/watch.ts | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/framework/hot.ts b/framework/hot.ts index bd1dc91..234533a 100644 --- a/framework/hot.ts +++ b/framework/hot.ts @@ -194,11 +194,11 @@ export function reloadRecursive(filepath: string) { } export function unload(filepath: string) { + lazyMarko?.markoCache.delete(filepath) filepath = path.resolve(filepath); const module = cache[filepath]; if (!module) return; delete cache[filepath]; - lazyMarko?.markoCache.delete(filepath) for (const importer of module.cloverImporters ?? []) { unload(importer.filename); } diff --git a/framework/marko.ts b/framework/marko.ts index 37c39cf..c865656 100644 --- a/framework/marko.ts +++ b/framework/marko.ts @@ -1,3 +1,4 @@ +console.log("MARKO"); export interface MarkoCacheEntry { src: string; scannedClientRefs: string[]; @@ -7,6 +8,7 @@ export const markoCache = new Map(); export function loadMarko(module: NodeJS.Module, filepath: string) { let cache = markoCache.get(filepath); + console.log({ filepath, has: !!cache }) if (!cache) { let src = fs.readFileSync(filepath, "utf8"); // A non-standard thing here is Clover Sitegen implements diff --git a/framework/watch.ts b/framework/watch.ts index 4fcf1f0..9bc7bf7 100644 --- a/framework/watch.ts +++ b/framework/watch.ts @@ -35,10 +35,10 @@ function onSubprocessClose(code: number | null, signal: string | null) { console.error(`Backend process exited with ${status}`); } -function rebuild(files: string[]) { - for (const file of files) { - incr.invalidate(file); - } +async function rebuild(files: string[]) { + const hasInvalidated = files.length === 0 + || (await Promise.all(files.map(incr.invalidate))).some(Boolean); + if (!hasInvalidated) return; incr.compile(generate.generate).then(({ watchFiles, newOutputs,