rewrite incremental #21
3 changed files with 7 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue