Skip to content

feat: memo resolved config - #95

Merged
lukeed merged 2 commits into
mainfrom
feat/config-memo
Nov 3, 2026
Merged

lukeed merged 2 commits into
mainfrom
feat/config-memo

Conversation

@lukeed

@lukeed lukeed commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

The memo key hashed the config file and the local files that it imports, but not the values that they give. A config that reads an environment variable, such as $site.url from DEPLOY, kept the pages of the last build when only the environment changed. Thus a staging build after a production build shipped production pages, unless it ran with --fresh. A data module that reads the environment or the network had the same problem.

  • memo.key() also hashes the resolved $site, $build, $images, and $data.
  • The entries of each Map and Set are part of the hash, since JSON writes them as {}.
  • The keys of each plain object are sorted first, so a value that a module builds in another order does not render every page again. Functions hash as their source. A value that cannot be written, such as a cycle, never matches, so its build renders every page: slower, never wrong.
  • Docs: the CLI page lists these values among the changes that render every page, and says that a function, such as a $utils helper that reads the environment when a page calls it, stays unseen.

Performance

bun run bench incremental, main against this branch, in both orders:

step main branch main branch
fresh 2.44 s 2.51 s 2.54 s 2.35 s
no change 248 ms 271 ms 275 ms 237 ms
body edit 248 ms 282 ms 283 ms 292 ms
title edit 329 ms 373 ms 369 ms 381 ms

The spread of main alone covers each difference: no change. The bench site has little $data. With 1.1 MB of $data, the sorted hash takes 9 ms for each build (plain JSON.stringify takes 0.9 ms; a hand-written serializer was no faster).

Test plan

  • A config value and a data module value from the environment each render every page when they change, and nothing when they do not (a build in a new process for each run; fails on main)
  • A change in a Map or a Set of a data module renders every page
  • bun run build, bun test, bunx tsc -p ., bunx tsc -p build

The memo key hashed the config file and its imports, but not the
values they give. A config that reads DEPLOY to pick its $site.url
kept the pages of the last build when only the environment changed,
so a staging build could ship production pages. The key now also
hashes $site, $build, $images, and $data, with object keys sorted
so an order that changes between builds does not render every page.
JSON writes a Map or a Set as {}, so a data module that changed
the entries of one kept the pages of the last build. Their entries
are now part of the key. The docs also say that a helper function
that reads the environment when a page calls it stays unseen.
@lukeed
lukeed merged commit 8c70ec7 into main Nov 3, 2026
4 checks passed
@lukeed
lukeed deleted the feat/config-memo branch November 3, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant