Skip to content

server: hatch build hook only watches package.json — wheel builds ship a stale frontend after source-only edits #136

Open

Description

@falbany

Problem

The packaging staleness check ignores every frontend source file:

# src/profiles/web/build_hook.py:17-28
def _needs_rebuild(web_dir: Path, marker_file: Path) -> bool:
    if not marker_file.exists():
        return True
    package_json = web_dir / "package.json"
    …
    return package_mtime > marker_mtime

Editing any .ts/.tsx/.css source after the last build and running hatch build / pip install . skips the rebuild entirely and packages the committed dist/ (possibly stale).

Related divergence between the two build paths (DRY violation per AGENTS.md):

  • build.py:141-149 deliberately runs npm install ("Use npm install instead of npm ci to handle lock file sync issues") — which can silently mutate package-lock.json during a "build" — while the hook runs npm ci. build.py also doesn't watch package-lock.json for staleness.
  • build_hook._run_npm_build uses capture_output=True and on failure prints only ERROR: npm build failed: {e} (build_hook.py:74-76) — e.stdout/e.stderr are discarded, so a failed packaging build gives no reason.

Suggested fix

  1. Extract a shared needs_rebuild() into web/build.py (scanning package.json + lock + **/*.{ts,tsx,css,html}) and have build_hook import it — or simply always run npm run build in the hook when npm is available.
  2. Standardize on npm ci --no-audit --no-fund in both (escape-hatch flag for lock drift in build.py).
  3. Print e.stderr (tail) on hook failure.

Activity

  1. added
    bug
    code-quality
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcode-quality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions