Fix frontend install cache invalidation from package.json formatting

Merged
FA
24d ago
+164-1

When bun or npm reformats .web/package.json, the next compile currently treats the new whitespace or key order as a dependency change and deletes the frontend install cache. Compare the rendered and on-disk manifests as parsed JSON objects so unchanged content preserves the file and cache. Reuse the existing manifest reader so missing, malformed, and non-object manifests are still repaired, including required framework scripts.

Fixes #7235.

Regression tests cover formatting and key order, repeated cached installs for both package managers, actual dependency changes, required scripts, and missing or invalid manifests. Five regression cases failed before the fix; all 122 tests in the affected modules pass afterward.

Validation:

  • WATCHFILES_FORCE_POLLING=true uv run --python 3.13 pytest tests/units --cov --no-cov-on-fail --cov-report=: 9,710 passed, 21 skipped, one upstream failure; 78.28% coverage.
  • uv run --python 3.13 ruff check .
  • uv run --python 3.13 ruff format --check .
  • uv run --python 3.13 pyright --pythonversion 3.14 reflex tests (the repository's configured Python target; an existing docgen test uses Python 3.14's dataclasses.field(doc=...))
  • Codespell on changed files and git diff --check

The initial full-suite run hit the host's file-watcher limit in two Granian reload tests (Too many open files, OS error 24). With polling enabled, only test_run_granian_backend_refuses_requests_while_the_app_is_broken fails because the backend port keeps accepting connections after the worker fails. That same failure reproduces in an isolated test on pristine upstream 7cac2fa, without this patch.