Skip to content

fix(build): build the viewer on npm install so a fresh clone can serve#13

Merged
benvinegar merged 1 commit into
mainfrom
fix/clone-quickstart-viewer-build
Jun 12, 2026
Merged

fix(build): build the viewer on npm install so a fresh clone can serve#13
benvinegar merged 1 commit into
mainfrom
fix/clone-quickstart-viewer-build

Conversation

@elucid

@elucid elucid commented Jun 12, 2026

Copy link
Copy Markdown
Member

Problem

The README quick start fails from a git clone:

$ git clone https://github.com/modem-dev/sideshow && cd sideshow
$ npm install
$ npx sideshow serve --open
viewer build missing — run `npm run build:viewer` first

Nothing in the from-clone install path builds viewer/dist/index.html, which the server reads at boot. The published npm package is unaffected — prepack ships a built viewer — so this papercut only hits people trying the repo itself, i.e. exactly the audience the quick start is for.

Fix

Chain the viewer build onto the existing prepare script:

"prepare": "simple-git-hooks && npm run build:viewer"

prepare runs on npm install/npm ci in the repo root only, so:

  • fresh clone + npm install + npx sideshow serve --open now just works
  • registry consumers are untouched (prepare doesn't run when installing the published tarball, and prepack already ships viewer/dist/)
  • vite is a devDependency, so it's always present when prepare runs
  • no conflict with the "no build step" philosophy: the server/CLI still run TypeScript directly; the viewer is already the codebase's one sanctioned build step (AGENTS.md), this just runs it where the quick start expects it

Alternatives considered

  • serve auto-builds when dist is missing and vite is available — more magic, bigger diff, and pulls build logic into the Node-builtins-only CLI. Rejected.
  • README-only fix (document npm run build:viewer) — smallest diff but leaves the papercut and another step to forget. Rejected.

Cost

  • CI: each npm ci now also runs a vite build (~0.3s on my machine, single-file viewer). The e2e job double-builds (Playwright global setup builds too) — negligible.
  • npm pack/npm publish: prepare runs before prepack, so the viewer builds twice during packing. Verified npm pack still produces a correct tarball (17 files, viewer/dist included).

Test evidence

Fresh clone in /tmp, on this branch:

$ rm -rf node_modules viewer/dist && npm install
...
✓ built in 312ms          # vite, via prepare
$ npx sideshow serve --port 4243
sideshow listening on http://localhost:4243
$ curl -sf localhost:4243/ | head -c 50
<!doctype html>
<html lang="en">...
$ curl -sf localhost:4243/api/sessions
[]

npm test, npm run typecheck, npm run lint, npm run format:check all pass.

The README quick start (npm install && npx sideshow serve --open) failed
from a git clone with `viewer build missing — run npm run build:viewer
first`: nothing in the install path built viewer/dist. Only the from-
clone path was broken — the published package ships a built viewer via
prepack.

Chain `npm run build:viewer` onto the existing prepare script. prepare
runs on npm install/ci in the repo root only, so registry consumers are
untouched, and vite is a devDependency so it is always present when
prepare runs. The viewer is already the codebase's one sanctioned build
step; this just runs it where the quick start expects it.
@benvinegar benvinegar merged commit de6b2ab into main Jun 12, 2026
6 checks passed
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.

2 participants