Skip to content

refactor(web): collect lexicons from their files instead of a hand-kept list - #296

Merged
botandbang merged 1 commit into
mainfrom
bnb/lexicon-registry
Oct 30, 2026
Merged

botandbang merged 1 commit into
mainfrom
bnb/lexicon-registry

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

What and why

apps/web/src/lib/server/atproto/lexicons.ts imported every file in lexicons/ by hand and listed it in LEXICON_DOCS, REFERENCED_DOCS or WRITTEN_DOCS, so every branch that added a lexicon edited the same lines. It now takes every document in lexicons/ and splits them by authority: computer.localnetwork.* is ours, everything else is referenced. All exports keep their names.

A #lexicon-files package import supplies the documents. Under Vite (the app, all Vitest projects, the build) a resolve.alias points it at an eager import.meta.glob, which bundles the JSON, since the production image doesn't ship lexicons/. Under tsx (the dev network, publish-lexicons) Node resolves it through package.json to a loader that reads the folder, since tsx has no import.meta.glob. publish-lexicons drops its own copy of that loader.

Two lexicons change lists. computer.localnetwork.locallibraryPublishing was missing from the old list; the dev network now validates and publishes it, as lexicons:publish already did (52 lexicons instead of 51). app.userinput.discussion moves to REFERENCED_DOCS: WRITTEN_DOCS only kept it out of HappyView's lookup, and no script indexes it.

How it was tested

  • New test in lexicons.test.ts: the loaded ids equal every JSON file on disk (read with the fs loader, so the two loaders agree), and the authority split holds. It fails when either loader drops a file.
  • format:check, lint, check, knip, test (723), test:storybook (159), test:build (3), test:coverage with integration (911 passed, lines 94.63%).
  • Ran the dev network under tsx: it published 52 lexicons. The production build inlines the JSON with no readdirSync.

Checklist

  • Tests cover the change
  • The READMEs, docs/ and --help still say what the code does (README no longer says to add lexicons to a list)

…pt list

lexicons.ts imported each file in lexicons/ by hand and listed it in
LEXICON_DOCS, REFERENCED_DOCS or WRITTEN_DOCS, so every branch that added a
lexicon edited the same lines. It now takes every document in lexicons/ and
splits them by authority: computer.localnetwork.* is ours, the rest are
referenced.

`#lexicon-files` supplies the documents. Under Vite (the app, its tests and
the build) an eager import.meta.glob bundles them, since the production image
doesn't ship lexicons/. Under tsx (the dev network, publish-lexicons) Node
resolves it through package.json to a loader that reads the folder, because
tsx has no import.meta.glob. publish-lexicons now uses LEXICON_DOCS instead of
its own copy of that loader.

Two lexicons change lists. computer.localnetwork.locallibraryPublishing, which
the list missed, is now validated and published by the dev network, as
lexicons:publish already did. app.userinput.discussion joins REFERENCED_DOCS:
WRITTEN_DOCS only kept it out of HappyView's lookup, and no script indexes it.
@botandbang
botandbang requested a review from bnb as a code owner October 29, 2026 21:13
@github-actions github-actions Bot added documentation Improvements or additions to documentation web The Local Network website (apps/web) web: server Spaces, sync, HappyView, the database and the server around them tests Tests, fixtures and test harnesses tooling Repo config, lint and build tooling, and GitHub settings labels Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Coverage Report for apps/web

Status Category Percentage Covered / Total
🟢 Lines 94.68% (🎯 93%)
🟰 ±0 pp
6452 / 6814
🟢 Statements 93.15% (🎯 91%)
⬆️ +0.01 pp
9915 / 10644
🟢 Functions 93.56% (🎯 92%)
🟰 ±0 pp
2532 / 2706
🟢 Branches 83.35% (🎯 80%)
🟰 ±0 pp
4652 / 5581
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/web/src/lib/server/atproto/lexicon-files.ts 100% 100% 100% 100%
apps/web/src/lib/server/atproto/lexicons.ts 100%
🟰 ±0 pp
91.66%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
Generated in workflow #555 for commit 635456c by the Vitest Coverage Report Action

Size

Compared with main. KiB are 1,024 bytes.

This pull request main Change
Client JavaScript 635.1 KiB 635.1 KiB 0 B (0%)
Client JavaScript, brotli 209.5 KiB 209.5 KiB 0 B (0%)
Client CSS 88.6 KiB 88.6 KiB 0 B (0%)
Client CSS, brotli 12.7 KiB 12.7 KiB 0 B (0%)

@botandbang
botandbang merged commit 30c548d into main Oct 30, 2026
50 checks passed
@botandbang
botandbang deleted the bnb/lexicon-registry branch October 30, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation tests Tests, fixtures and test harnesses tooling Repo config, lint and build tooling, and GitHub settings web: server Spaces, sync, HappyView, the database and the server around them web The Local Network website (apps/web)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants