fix(docs): cap vite below 7 (rolldown-vite) and pin mermaid transitives #161
Reference in New Issue
Block a user
Delete Branch "fix/docs-site-cap-vite-below-rolldown"
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?
Summary
pnpm docs:devfailed after #159's transitive-vuln fix landed. Two distinct symptoms in the same log :VitePress refused to boot —
VitePress v1 is not compatible with rolldown-vite. Use VitePress v2 instead.The override added in #159 (vite@<6.4.2 → >=6.4.2) had no upper bound; pnpm resolved vitepress'svite ^5.0.0constraint up to vite 7.3.2, which uses the new rolldown bundler. VitePress 1.x explicitly rejects rolldown-vite.Resolution-warning flood — Even on a fallback port, the console showed
Failed to resolve dependency: dayjs / debug / @braintree/sanitize-url / cytoscape / cytoscape-cose-bilkentfromoptimizeDeps.include. The vitepress-plugin-mermaid wrapper injects those into the optimizer's include list, but under pnpm's strict isolation they aren't reachable from the workspace root (transitives of mermaid, never hoisted).What lands
1. Vite override is now an unconditional
>=6.4.2 <7rangepackage.json:The selector form (
vite@<6.4.2) was a no-op once vite had resolved into 7.x — the override only activates when the resolved version is in the vulnerable range. Vite 7 is ≥ 6.4.2, so the override stayed dormant and rolldown-vite slipped through.The unconditional form forces a downgrade across every consumer (vitepress,
@nx/vite,@analogjs/vite-plugin-angular, Vitest, etc.). All six top-level projects still lint, test, and build under vite 6.4.2.Trade-off acknowledged: we're now pinning the whole workspace to vite 6.x to keep VitePress 1.x happy. The day VitePress 2 ships a 1.0 (currently in beta), we revisit and let vite advance again. Tracked as a soft follow-up.
2.
optimizeDeps.includesimplified to['mermaid']docs/.vitepress/config.mts:Vite 6's dep optimizer walks Mermaid's transitives automatically once Mermaid itself is in
include. The explicit child list from #157 was carried forward in the rolldown attempt and tripped on vite's stricter resolver — collapsing it now both removes the noise and matches what the plugin's docs recommend for vite 6.3. Mermaid transitives pinned as top-level devDeps
package.json:These are already in
node_modules(pulled in by mermaid). Declaring them at the workspace root makes them reachable fromoptimizeDeps.includeunder pnpm's strict isolation, which silences the five "Failed to resolve dependency" warnings the plugin's wrapper produced.Cost: five extra devDep lines in
package.jsonwhose only purpose is to make the optimizer happy. Acceptable — they don't influence the resolved tree, just the resolver's reachability rules.Notes for the reviewer
vite@vulnerable-range → patched-range) is the standard pattern when the parent dep's own range includes a patched version — pnpm picks it naturally and the override never fires. Here vite's 5.x branch was never patched (5.4.21 stayed vulnerable; vite team moved on to 6.x), so we need to force the downgrade from 7.x to 6.x regardless of the previous resolution. An unconditional override is the cleanest expression of that intent.Test plan
pnpm installclean; lockfile changes reflect vite 6.4.2 across all consumers.pnpm audit --audit-level=moderate— No known vulnerabilities found.pnpm docs:dev— server boots cleanly on:5173, no warnings, home + ADR-0009 page return 200.pnpm docs:build— clean build in ~9 s (back to Rollup-based timings; the rolldown 3.87 s we saw briefly was the incompatible path).pnpm exec nx run-many -t lint test --projects=portal-shell,portal-admin,portal-bff,shared-ui,shared-state,feature-auth— 12/12 tasks green under the vite 6 downgrade.pnpm exec nx build portal-shell— clean Angular production build; no Vite 6 incompatibility surfaced.pnpm docs:dev, openhttp://localhost:5173, navigate to/decisions/0009-…and/architecture, confirm Mermaid diagrams render inline (this is the actual UX the user opened the issue on). Dark mode toggle still flips diagrams.Follow-ups (optional)
vue/vitepress > releases), revisit this override and let vite resume its mainline cadence.cytoscape/dayjs/debugmajor bump that VitePress 1.x can't keep up with, the pins above act as the safety net — Renovate will open a PR rather than silently break the dev server.