Hub vite server crashes on dep-scan: "virtual:pwa-register imported by tasks-app/main.ts could not be resolved" #74
Labels
No labels
app:activities
app:chat
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp#74
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
On
pnpm run dev:all(or any fresh hubpnpm run devwith a coldnode_modules/.vite-hub/cache), the hub vite server crashes:The hub never starts. Standalone vite servers (tasks, activities,
wallet, …) start fine because each has its own
vite.<app>.config.tswith
VitePWA(...)registered.Root cause
Vite's
optimizeDepsscanner walks all*.htmlfiles in the projectroot by default. The repo root has 9 standalone HTML entries
(
tasks.html,activities.html,wallet.html, etc.) in addition toindex.html. Each standalone HTML points atsrc/<app>-app/main.ts,all of which begin with:
virtual:pwa-registeris supplied byvite-plugin-pwa. Percommit
0a07691(fix(hub): drop hub PWA install to unblock standalone PWAs (closes #41)) the hub'svite.config.tsintentionally omits VitePWA — the hub is a launcher, not a PWA. So
when the hub's scanner crawls
tasks.html→tasks-app/main.ts→virtual:pwa-register, resolution fails and Vite refuses to startthe dev server.
The bug has been latent since #41 shipped; it only surfaces when
the hub's
.vite-hub/cache is cold (e.g. fresh worktree install,vite --force, dep version change). Once the cache is warm, thescanner skips the standalone entries and the hub starts cleanly.
Reproduction
Or:
Proposed fix
Constrain the hub's
optimizeDeps.entriesto justindex.html.The hub serves the launcher page; the standalones each run on their
own vite port via
dev:<app>and don't need to be scanned by thehub.
One-liner functionally, two with the comment. No standalone config
changes needed.
Why this is the right fix (not "add VitePWA to the hub")
Re-adding VitePWA to the hub would resurface the #41 install-prompt
shadowing — the hub at
/claiming SW scope blocks Chrome fromoffering installs for the path-mounted standalones at
/tasks/,/market/, etc. The optimizeDeps scope fix keeps the hub's intentintact while preventing the cold-cache crash.
Out of scope
dev:<app>scripts. They're neededfor subdomain-style standalone serving and isolated port
binding.
before; per #41 the SW-scope collision makes it worse, not
better.
Test plan
rm -rf node_modules/.vite-hub && pnpm run dev→ hubstarts on
:5173without thevirtual:pwa-registererror.pnpm run dev:allcold-starts cleanly; all 9 vite serverscome up.
pnpm run buildandpnpm run build:demoremain unaffected (the
optimizeDepsflag is dev-only).localhost:5181/activities.htmloffers Install).