fix error conditions

This commit is contained in:
clover caruso 2025-08-02 20:20:04 -04:00
parent b6a172a160
commit 5a07485601
3 changed files with 7 additions and 5 deletions

View file

@ -194,11 +194,11 @@ export function reloadRecursive(filepath: string) {
} }
export function unload(filepath: string) { export function unload(filepath: string) {
lazyMarko?.markoCache.delete(filepath)
filepath = path.resolve(filepath); filepath = path.resolve(filepath);
const module = cache[filepath]; const module = cache[filepath];
if (!module) return; if (!module) return;
delete cache[filepath]; delete cache[filepath];
lazyMarko?.markoCache.delete(filepath)
for (const importer of module.cloverImporters ?? []) { for (const importer of module.cloverImporters ?? []) {
unload(importer.filename); unload(importer.filename);
} }

View file

@ -1,3 +1,4 @@
console.log("MARKO");
export interface MarkoCacheEntry { export interface MarkoCacheEntry {
src: string; src: string;
scannedClientRefs: string[]; scannedClientRefs: string[];
@ -7,6 +8,7 @@ export const markoCache = new Map<string, MarkoCacheEntry>();
export function loadMarko(module: NodeJS.Module, filepath: string) { export function loadMarko(module: NodeJS.Module, filepath: string) {
let cache = markoCache.get(filepath); let cache = markoCache.get(filepath);
console.log({ filepath, has: !!cache })
if (!cache) { if (!cache) {
let src = fs.readFileSync(filepath, "utf8"); let src = fs.readFileSync(filepath, "utf8");
// A non-standard thing here is Clover Sitegen implements // A non-standard thing here is Clover Sitegen implements

View file

@ -35,10 +35,10 @@ function onSubprocessClose(code: number | null, signal: string | null) {
console.error(`Backend process exited with ${status}`); console.error(`Backend process exited with ${status}`);
} }
function rebuild(files: string[]) { async function rebuild(files: string[]) {
for (const file of files) { const hasInvalidated = files.length === 0
incr.invalidate(file); || (await Promise.all(files.map(incr.invalidate))).some(Boolean);
} if (!hasInvalidated) return;
incr.compile(generate.generate).then(({ incr.compile(generate.generate).then(({
watchFiles, watchFiles,
newOutputs, newOutputs,