Files
ps5upload/client/src/lib/lazyWithReload.app.test.ts
T
PhantomPtrandClaude Opus 5.5 e6e8601363 Files crash: reload on a missing screen chunk; make keeps node_modules; dev FAQ/changelog (#340)
* fix(app): a screen whose code is gone reloads the page instead of crashing

Screens load on demand; when a screen's file can't be fetched the
import rejects ('Importing a module script failed') and the route showed
the crash screen. That happens to a web UI tab left open across an
update (it asks for file names the new build doesn't have) and to a dev
server whose dependency cache was rebuilt under it. Reproduced by
swapping the served build under an open tab: main showed the crash
screen for Files; now the page reloads once and opens Files from the
new build. A second failure within 30 s shows the error, so an outage
can't reload forever.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(make): don't reinstall client dependencies that already match the lockfile

setup-client ran npm ci on every make (run-client, run-android, emu-test,
dist-*). npm ci deletes node_modules first — Vite's dependency cache
with it — so a dev server already running lost its cache and its
screens failed ('Importing a module script failed' on Files). It now
reinstalls only when package-lock.json or Node changed since the last
install (a stamp in node_modules). Checked: a make during a running dev
server leaves it working; a stale stamp still reinstalls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dev): the FAQ and What's New screens load on the dev server

They imported the repo-root FAQ.md and CHANGELOG.md with ?raw, and the
dev server served those (outside the client folder) as raw markdown
instead of modules. A small Vite plugin exposes them as virtual modules,
which go through the normal pipeline in dev and in builds (each is its
own on-demand chunk, locally and in the Docker web UI build). New e2e
test: both screens show their document.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): 5.37.2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 16:47:36 -07:00

15 lines
607 B
TypeScript

import { describe, expect, it } from "vitest";
// A bare React.lazy screen shows the crash screen when its code can't be fetched after an update.
const APP = Object.values(
import.meta.glob("../App.tsx", { query: "?raw", import: "default", eager: true }) as Record<string, string>,
)[0];
describe("screens loaded on demand", () => {
it("all go through lazyWithReload", () => {
expect(APP.length).toBeGreaterThan(1000);
expect(APP).not.toMatch(/(?<![A-Za-z])lazy\(\s*\(\)\s*=>\s*import/);
expect((APP.match(/lazyWithReload\(\(\) => import\(/g) ?? []).length).toBeGreaterThan(30);
});
});