Skip to content

build: run knip in production mode too - #546

Queued
botandbang wants to merge 6 commits into
mainfrom
bnb/knip-production
Queued

botandbang wants to merge 6 commits into
mainfrom
bnb/knip-production

Conversation

@botandbang

@botandbang botandbang commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #544. Stacked on #545.

pnpm knip now runs knip twice: over everything, as #545 set up, then with --production, which counts only the code that ships. That run finds what the first can't: exports and files that only tests, stories or scripts use. Each app's CI and the repo-checks knip job call pnpm knip, so they run both.

Added

  • Production markers in knip.jsonc. A pattern ending in ! is production code; one wrapped in !…! is left out of the production run only, and the default run ignores it.
    • apps/web: ! on the #lexicon-files entry and on scripts/db-backup.ts, which the Docker image ships for restores. Knip's default run calls the second redundant (a configuration hint, not an error) because package.json's db: scripts reach it, but the production run only reads start. The project keeps knip's default extensions with ! and leaves out scripts/, tests/, .storybook/, lighthouserc.cjs, src/lib/testing and src/lib/server/testing, *fixtures.ts, and FormActionsHarness.svelte and CardPreview.svelte (both story-only).
    • apps/localtoolbox: ! on content.ts, downloaded-store.ts, state-transfer.ts and content.css, which vite.config.ts builds or copies as they are. The project leaves out test/, scripts/ and stryker-load-time.mjs.
    • The root and Bombadil get a project without !, so their tooling stays out of the production run and the default run still covers it.
  • @internal on exports that only tests, stories or scripts use, which the production run skips:
    • localtoolbox: HOSTS (sites/index.ts), which test/consistency.test.ts checks the manifest's host_permissions against, and CLAIMED (the same file) and VARIABLE_NAMES (search-sites.ts), which only their own tests read.
    • web: epkFormDefaults (epk.ts) and riddenReport (mix/sample.ts), for stories and tests; publishLexicons (server/atproto/lexicons.ts) and HAPPYVIEW_PERMISSIONS (server/happyview/client.ts), for the dev network's scripts; silentLogger (server/logger.ts), for tests and scripts; overdue (server/flags/catalog.ts), which only tests call so that a passing date never breaks a build.

Changed

  • The root's knip script runs knip && knip --production.
  • .github/NEW_PROJECT.md describes the two runs, @internal, and marking a new app's shipped entry files with !.

Removed

  • isSpaceType in apps/web/src/lib/server/atproto/spaces.ts: nothing called it but its test. The two assertions on it in spaces.test.ts go with it.
  • CALENDAR_RSVP from apps/web/src/lib/nsid.ts: only oauth.test.ts read it, to check that sign-in doesn't ask to write RSVPs. The constant moves into that test.
  • Badge.svelte, BrowserFrame.svelte and SelectField.svelte from apps/web/src/lib/ui: no page used them, only their stories and tests. Removed with them: BrowserFrame.stories.svelte, the Badge story in Tag.stories.svelte (now titled "Primitives/Tag"), the Select story in Fields.stories.svelte, and their tests in ui.svelte.test.ts. The hero preview story in HomepageProposals.stories.svelte keeps its project page without the browser frame around it.

--strict stays off. It reports svelte, @sveltejs/kit and the other devDependencies the apps import, which is how SvelteKit apps list what Vite bundles.

To check: pnpm knip at the root exits 0. With an export only a test imports in apps/web/src/lib/format.ts, an unused export in tools/budgets/budgets.ts, and an unimported file in apps/localtoolbox/src/lib, the default run failed on the last two and the production run on the first and last.

isSpaceType had no caller but its own test, so it goes, with the two
assertions on it. CALENDAR_RSVP was only read by the OAuth tests, which
check that sign-in doesn't ask to write RSVPs; the constant moves into
that test file.

Badge, BrowserFrame and SelectField in the design system had no page
using them, only their stories and tests, which go with them. The
homepage proposals' hero preview story keeps its project page without
the browser frame around it, and the Tag stories drop "and badge" from
their title.
`pnpm knip` now runs knip twice: over everything, as before, then with
--production over only the code that ships. knip.jsonc marks the
shipped entry files and project globs with `!`: the web app's routes
(through the SvelteKit plugin), its #lexicon-files target and
scripts/db-backup.ts, which the Docker image ships, and localtoolbox's
content script, classic scripts and content.css. Tests, scripts, test
and story helpers, the root's tools/ and Bombadil stay out of the
production run.

Exports that only tests, stories or scripts use are tagged @internal,
which the production run skips: HOSTS, CLAIMED and VARIABLE_NAMES in
localtoolbox, and epkFormDefaults, riddenReport, publishLexicons,
HAPPYVIEW_PERMISSIONS and silentLogger in the web app.
@botandbang
botandbang requested a review from bnb as a code owner November 10, 2026 20:26
@github-actions github-actions Bot added documentation Improvements or additions to documentation web The Local Network website (apps/web) localtoolbox The localtoolbox Chrome extension web: mixes Mixes, their tracklists and mix reports web: epk Press kits and who can see them web: accounts Signing in, sessions and the account pages web: server Spaces, sync, HappyView, the database and the server around them web: ui Shared components, design tokens, layout and the static pages localtoolbox: core The menu, session queue, settings, saved state and shared code localtoolbox: downloads The third-party downloads tool tests Tests, fixtures and test harnesses tooling Repo config, lint and build tooling, and GitHub settings labels Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Coverage Report for apps/localtoolbox

Status Category Percentage Covered / Total
🟢 Lines 100% (🎯 100%)
🟰 ±0 pp
4461 / 4461
🟢 Statements 100% (🎯 100%)
🟰 ±0 pp
6041 / 6041
🟢 Functions 100% (🎯 100%)
🟰 ±0 pp
1762 / 1762
🟢 Branches 98.6% (🎯 50%)
🟰 ±0 pp
2889 / 2930
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/localtoolbox/src/lib/search-sites.ts 100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
apps/localtoolbox/src/tools/third-party-downloads/sites/index.ts 100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
Generated in workflow #667 for commit b25eaf6 by the Vitest Coverage Report Action

Size

Compared with main. KiB are 1,024 bytes.

This pull request main Change
Packaged (localtoolbox.zip) 360.3 KiB 360.3 KiB -2 B (-0%)
Unpacked (dist/) 810.8 KiB 810.8 KiB 0 B (0%)

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Coverage Report for apps/web

Status Category Percentage Covered / Total
🟢 Lines 99.76% (🎯 99%)
🟰 ±0 pp
11284 / 11311
🟢 Statements 99.44% (🎯 99%)
🟰 ±0 pp
17283 / 17380
🟢 Functions 99.59% (🎯 99%)
🟰 ±0 pp
4671 / 4690
🟢 Branches 94.69% (🎯 94%)
🟰 ±0 pp
8468 / 8942
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/web/src/lib/epk.ts 100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
apps/web/src/lib/nsid.ts 100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
apps/web/src/lib/mix/sample.ts 100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
apps/web/src/lib/server/logger.ts 100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
apps/web/src/lib/server/atproto/lexicons.ts 100%
🟰 ±0 pp
95.65%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
apps/web/src/lib/server/atproto/spaces.ts 100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
apps/web/src/lib/server/flags/catalog.ts 100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
apps/web/src/lib/server/happyview/client.ts 100%
🟰 ±0 pp
96.77%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
Generated in workflow #667 for commit b25eaf6 by the Vitest Coverage Report Action

Size

Compared with main. KiB are 1,024 bytes.

This pull request main Change
Client JavaScript 810.1 KiB 810.1 KiB 0 B (0%)
Client JavaScript, brotli 274.5 KiB 274.4 KiB +32 B (+0%)
Client CSS 99.2 KiB 99.6 KiB -439 B (-0.4%)
Client CSS, brotli 14.3 KiB 14.4 KiB -87 B (-0.6%)

Base automatically changed from bnb/knip to main November 10, 2026 20:42
bnb
bnb previously approved these changes Nov 10, 2026
botandbang and others added 3 commits November 10, 2026 15:46
main brought in overdue() (flags/catalog.ts), which only tests call so a passing date never breaks a build. The production knip run skips exports tagged @internal.
@github-actions github-actions Bot added the web: staff Admin, moderation and the audit log label Nov 10, 2026
@botandbang
botandbang added this pull request to the merge queue Nov 11, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
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 localtoolbox: core The menu, session queue, settings, saved state and shared code localtoolbox: downloads The third-party downloads tool localtoolbox The localtoolbox Chrome extension tests Tests, fixtures and test harnesses tooling Repo config, lint and build tooling, and GitHub settings web: accounts Signing in, sessions and the account pages web: epk Press kits and who can see them web: mixes Mixes, their tracklists and mix reports web: server Spaces, sync, HappyView, the database and the server around them web: staff Admin, moderation and the audit log web: ui Shared components, design tokens, layout and the static pages web The Local Network website (apps/web)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tooling: run knip over the whole repo, in production mode too

2 participants