rewrite incremental #21

Merged
clo merged 7 commits from incremental-2 into master 2025-08-02 17:31:59 -07:00
3 changed files with 7 additions and 5 deletions
Showing only changes of commit 5a07485601 - Show all commits

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,