Skip to main content

Decisions — the code

Rendered from corpus/wiki/decisions-code.md · updated 2026-11-02

This page is generated from the project corpus and rewritten on every docs build. Edit the source in corpus/, not here.

Settled calls about how the code is put together. The calls about the product and how it looks are in decisions.md; the two were one file until it outgrew the corpus's 200-line rule.

Each is here because it is hard to reverse, surprising without context, and was a genuine trade-off. Changing one needs an explicit revisit and a log.md note — not a quiet flip.

A hand-written service worker, not Workbox​

before 2026-08-31, retired 2026-10-28 — Four caches with four lifetimes, written out and served as-is, plus a build plugin that stamps the finished file list into it. Rejected: Workbox — what a browser keeps after the tab closes is the thing you most need to be able to read in one sitting, and a generated worker is not that. Retired 2026-10-28 with offline support (decisions.md). The plugin is gone; what is left is public/sw.js, a hand-written worker that removes itself, served as-is.

Grouped by feature, dependencies one way​

before 2026-08-31 — trips/schema ← everything, then lib → features → app. A component used by exactly one chapter lives in that chapter. Rejected: grouping by file kind (components/, pages/, data/) — it puts the two files you edit together at opposite ends of the tree. See architecture.md.

A trip's guide is a sibling directory, not a child​

before 2026-08-31 — belgium-guide/ sits beside belgium/, and one file per city inside it. Reason: it is a separately-loaded chunk (~170 kB) and nothing may reach it eagerly; a child directory invites an index that imports it. One file per city because a chapter is the unit you actually edit.

A trip is an eager meta and a lazy content, and the week is declared once​

2026-09-01, superseding a 2026-08-31 call — Each trip is <place>/meta.ts (areas, the week, what the bar and the shelf say — under a kilobyte, and it must never import the content) plus <place>/index.tsx (the TripContent, behind the meta's load()). trips/index.ts is the list.

What changed. The old call was "the registry declares week and chapters rather than deriving them, and TripOutlet warns when they drift". The reasoning was right and is unchanged — the bar and the shelf paint before any content is fetched, so deriving from content would pull ~380 kB into the first chunk. What was wrong was accepting three copies and watching one pair of them.

A day's number, weekday, area and place were written in days.tsx, again in pricing.tsx, and a third time in the registry as a 'Sat travel' string. The drift check compared the registry against days, because that is the pair somebody thought to check. The third copy was unwatched, and it had drifted: Belgium's Day 3 was "Ghent or the coast · then the Rubens walk" in the itinerary and "Ghent · and the Rubens walk at dusk" on the pricing page.

defineWeek (src/trips/week.ts) declares it once; days and pricing.days spread week.day(n), and week.ticks is the shelf's. Day numbers come from the position, so they cannot skip or repeat, and a typo'd area key throws at import instead of drawing a colourless rail. Cost: the eager chunk grew ~0.6 kB gzipped, because the day labels are now in it. chapters is still declared — it genuinely cannot be derived — but it is one table in Layout now rather than three statements.

Tailwind, but no Preflight​

before 2026-08-31 — Only tailwindcss/theme.css and tailwindcss/utilities.css are imported. Reason: the site's prose is the trip data — thousands of unclassed <table>, <td>, <h3> and <li> elements styled by element selectors. Preflight would restyle all of it. Consequence: element defaults are ours, in @layer base.

Page CSS lives beside the component that writes it​

2026-08-31 — src/styles/ holds only what is the site's (element defaults, the shared measure, footer, two global media queries). Revised 2026-10-07 (owner): the table look moved into ui/Table, and .panel and .sec-head:first-child became utilities (pt-[26px], first:mt-[34px]), so styles.css holds no page classes. Fingerprint: 29,704 elements, 0 diffs. Everything else moved out: app/shell.css, and one stylesheet per chapter that needs CSS a utility cannot express. Rejected: one styles.css for the whole site — it was the last place code was grouped by kind of file rather than by what it is for, and it had been accreting page classes from six chapters. footer is the explicit exception: the poster route renders outside the shell and writes its own footer as an override of those element defaults, so they stayed global. Proven a no-op with the fingerprint harness (12,778 elements, 0 diffs). See styling.md.

theme.css is the only definition of a value​

2026-08-31 — Every stylesheet spells the token out (var(--color-ink)). The short aliases (--ink, --paper-2, --radius) were scaffolding for that migration and have been deleted. Reason: two spellings of one value is two places to change it. The aliases were kept only while rules were still leaving styles.css; that finished, so they went.

No test suite; a DOM fingerprint harness instead​

before 2026-08-31 — build, lint, tools/fingerprint/ and the poster render are the whole gate. Reason: what breaks here is layout and cascade, which unit tests do not see. The harness records ~38 computed properties per element keyed by DOM position, so it catches a change that rewrites every class attribute — fourteen real bugs so far. Playwright is deliberately not a dependency (~300 MB with browsers for something run by hand a few times per change); the harness borrows one from a sibling project.

Leaflet's stylesheet was excluded from the Leaflet chunk (retired)​

before 2026-08-31, retired 2026-10-24 — manualChunks returned undefined for leaflet/*.css: including it made the chunk an eager dependency of the entry, and Vite modulepreloaded all 150 kB on every route. Retired with Leaflet (2026-10-24). MapLibre's stylesheet is imported by MapView, the lazy module that uses it, so it loads with the map; Vite runs a lazy chunk only once its CSS has loaded, which was the reason for the eager import. Keep a lazy library's stylesheet out of main.tsx.

The poster is Chrome printing the site's own components​

before 2026-08-31 — npm run poster starts Vite, dumps the rendered DOM, inlines every asset as a data: URI, then prints the PDF from that file. Rejected: a canvas/SVG poster library — the poster reads the site's own trip data, so it cannot drift from the itinerary. The self-contained HTML is the deliverable, not a by-product: it has no external references, so it opens and prints anywhere, offline. Node fetched every asset and threw on anything that was not a 200, instead of Chrome racing 21 downloads against a countdown. See poster/RECIPE.md. Since 2026-10-01 the render refuses a poster that clips — measured on that self-contained file, naming the day — and refuses an unknown slug rather than printing the first trip.

TRIPS_HIDDEN removes a trip from the build, not from the page​

2026-09-11 — A Vite plugin (tools/hidden/) deletes the registry's import of <slug>/meta before Rollup sees it; that import is the only path to the trip's content, so the whole directory falls out — no chunk, nothing in the precache list. Set where the build runs, never in the source. Rejected: a flag or condition in the shell — this is a static site, so a hidden trip's meta would stay in the entry chunk and its chunk name in the worker's precache manifest: not hidden, merely not linked. It fails rather than half-works: an unknown slug, a registry shape it no longer recognises, an empty shelf, or the hidden slug found anywhere in the written output (closeBundle, every text file in dist/) all stop the build. The output scan is skipped after a failed build (2026-10-21): dist/ then still holds the previous build, and a leak found in that stale tree used to replace the real error in the terminal. The match is case-sensitive on the slug, so routes, filenames and data are caught and an essay that names another destination in prose is left alone. It does not reach the docs site, which is why the corpus must not date a trip (corpus/CLAUDE.md). See README § "Hide a trip while you are taking it".