Repository navigation
Description
bongo build renders every page on each run. On a large site, a run after a one-line edit costs the same as the first run: about 4 s for the 10,000-page site of bun run bench (#56). This issue makes a build render again only the pages whose output can change, and keeps the output byte for byte the same as a full build.
Prerequisite
#60: bongo build writes over public/ and deletes only stale files, so an unchanged page can keep its file.
Cache
Keep the state of the last good build in node_modules/.cache/bongo/, next to the image and render caches:
- A hash of each global input (see below).
- For each content file: a hash of its source, its frontmatter signature, the record that
$pagesholds for it (path, url, title, summary, section, tags, headings, params, alternates), its output path, the placeholders of its assets, its renders, and what it read (see below). - The output name and the hash of each asset.
- The list of output files.
A clean checkout, such as on CI, has no cache, so it builds everything.
What a page reads
Template values come from code, so bongo cannot know them ahead of time. It can see them while a page renders. Give each page's scope getters for $pages, $section, and $tags, which record each read. Partials see the scope of the page that renders them, so their reads count for that page too. Record, for each page:
- whether it read
$pages; - whether it read
$section, and which section; - whether it read
$tags.
When to render again
- Everything, when a global input changes: the version of bongo, the config file and each local file it imports, each file in
data/,layouts/, andpartials/, the versions of the plugins and loaders, and the options of the run, such as--minify. - A page whose source changed.
- Each page that read a registry that changed. A page is added or deleted, or its record changes, such as a new title, tags, or headings. Then render again each page that read
$pages; each page that read$section, for each section that changed; and each page that read$tags, when a tag list changed. Adding one post thus renders that post, its section index, and the pages around it, not the whole site. - Each page that uses an asset whose output name or content changed, such as a root stylesheet. This can render the page again, or put the new names into HTML that the cache kept with its placeholders.
- Output files and data modules, on every build. They read
$pages, and there are few of them.
A page that does not render again keeps its file in public/, unless the file is missing or was changed outside bongo.
Limits
- A template that reads a value bongo does not track, such as
Date.now(), an environment variable, or a file that a TypeScript partial opens, keeps its last output until something above renders it again. Document this, and add a flag for a full build, such as--fresh. $hooks.transformruns only on pages that render again.
Measure
Add scenarios to bun run bench: no change, one body edit, one frontmatter edit, one new page, an edit to layouts/html.hbs, and an edit to the root stylesheet. Report the time and peak RSS of each.
Acceptance
- For each scenario, the files of an incremental build are byte for byte the same as those of a full build of the same sources.
- A change to any global input gives a full build.
- With no change, a build of the 10,000-page bench site takes a small part of a full build.
Activity
lukeed commentedon Oct 15, 2026
Design, with the decisions from the discussion: one engine for
bongo buildand dev, a hash of every source, stable asset names in dev, and--fresh.Memo
After each build, bongo keeps a memo of it.
bongo buildsaves it innode_modules/.cache/bongo/build/. Dev keeps it in memory. It holds:--minify, dev), the config and each local file it imports, each file indata/,layouts/, andpartials/, and the nearest lockfile, which covers plugin versions. If it changes, or--freshis given, the build renders everything.$pagesas it is, and its body is loaded only if the page must render again.<bongo:alternate>elements, the files that$assets.loadread (with hashes), a signature of its assets after the flush, and the size and mtime of its output file.$pages, of each section, and of$tags, from the records.What a page reads
tempura reads every declared value as a template starts, so getters cannot see what a template uses. Instead, a page reads a registry if its
.hbsbody, a layout of its chain, or a partial that it called names$pages,$section, or$tags. A partial in TypeScript or JavaScript counts as reading all three. Templates can reach a registry only by its name, so this can over-count, but it never misses. It also costs nothing per access, unlike a Proxy on each array.When a page renders again
A page renders again when the global key changed, its source changed, a registry that it read has a new hash, a file that it loaded changed, or its output file is missing or was changed outside bongo. Otherwise it keeps its file, and its asset registrations, renders, and alternates are replayed, so the bundler, output files, data modules, and the sweep see the whole site.
After the bundler flush, a page whose assets got new output names renders again too. In dev, scripts and stylesheets keep stable names, so an edit to a stylesheet changes no page; inline assets count by content.
Output files and data modules run on every build, since they read
$pages, and there are few of them.$hooks.transformruns only on pages that render again.Dev's narrow rebuild (
only, and the frontmatter signature that promotes it) is replaced by this engine.Limits
A template that reads a value the memo does not track, such as
Date.now(), an environment variable, or a file that a partial opens, keeps its last output until something above renders it again.--freshbuilds everything.Measure
bun run benchadds build scenarios, each checked byte for byte against a fresh build of the same sources: no change, a body edit, a frontmatter edit, a new page, a layout edit, and a stylesheet edit. The dev scenario adds a stylesheet edit and a new page.docs: record #66 steps
feat: incremental builds
docs: record #66 results
docs: record #66 results
docs: record #66 steps