rewrite incremental #21

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

View file

@ -1,3 +1,8 @@
// This file contains the main site generator build process.
// By using `incr.work`'s ability to cache work between runs,
// the site generator is very fast to re-run.
//
// See `watch.ts` for a live development environment.
const { toRel, toAbs } = incr; const { toRel, toAbs } = incr;
const globalCssPath = toAbs("src/global.css"); const globalCssPath = toAbs("src/global.css");

View file

@ -1,4 +1,9 @@
// Incremental compilation framework // Incremental build system using singleton state.
// See `work()`, `compile()`, and `invalidate()` for details.
//
// All state is serializable to allow recovering state across sessions.
// This framework special-cases the asset map, but is otherwise
// agnostic of what it is a compiler for.
let running = false; let running = false;
let jobs = 0; let jobs = 0;
let newKeys = 0; let newKeys = 0;
@ -85,7 +90,7 @@ export function work<I, O>(job: Job<I, O>, input: I = null as I): Ref<O> {
} }
export async function compile<T>(compiler: () => Promise<T>) { export async function compile<T>(compiler: () => Promise<T>) {
ASSERT(!running, `Cannot run twice`); ASSERT(!running, `Cannot run twice at the same time.`);
try { try {
running = true; running = true;
ASSERT(jobs === 0); ASSERT(jobs === 0);