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) {
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);
}

View file

@ -1,3 +1,4 @@
console.log("MARKO");
export interface MarkoCacheEntry {
src: string;
scannedClientRefs: string[];
@ -7,6 +8,7 @@ export const markoCache = new Map<string, MarkoCacheEntry>();
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

View file

@ -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,