You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[TASK] Refactor duplicated Mermaid chunk regex in .vitepress/config.ts into one constant #1236
.vitepress/config.ts defines the list of lazy Mermaid chunk names twice, as two hand-copied regex alternations: once inside transformHtml (strips the <link rel="modulepreload"> tags from the built HTML) and once inside vite.build.modulePreload.resolveDependencies (filters the same chunks out of the JS preload list). Both copies carry the identical alternation [A-Za-z0-9]*Diagram-|diagram-|classDiagram|stateDiagram|wardley(?:Diagram)?-|dagre-|cose-bilkent-|cytoscape\.esm|katex|sankey|kanban-definition|timeline-definition|mindmap-definition|virtual_mermaid.
The two filters only work as a pair - a chunk name added to one and not the other silently reintroduces an eager preload - so every Mermaid upgrade that renames or adds a diagram chunk needs the same edit in two 300-character lines that sit almost 300 lines apart. Nothing in the file says the two lists are related.
Principle applied - clean-code: duplication (the same constant defined in several places) and magic values that hide intent. The fix is local to one file: name the list once next to the other top-level constants (HOSTNAME, SITEMAP_*) and build both regexes from it.
Acceptance Criteria
Before: the Mermaid chunk alternation is written out inline in both transformHtml and vite.build.modulePreload.resolveDependencies. After: one top-level constant in .vitepress/config.ts (for example LAZY_MERMAID_CHUNK_NAMES, holding the alternation source) is the only place the chunk names appear.
Before: transformHtml holds a 300-character regex literal. After: it uses a regex built from the shared constant (a second top-level constant such as LAZY_MERMAID_PRELOAD_LINK is fine), with the same <link ... rel="modulepreload" ... /assets/chunks/...> wrapper and the g flag.
Before: resolveDependencies holds its own copy of the alternation behind (?:^|\/). After: it tests against a regex built from the same shared constant.
bun run build output is unchanged: the built index.html contains no modulepreload link for the Mermaid, dagre, cytoscape or katex chunks, same as before.
Existing tests still pass (bun test, bun run format:check, bun run lint:md).
Done. Issue #1236 is resolved in PR #1243 (ready for review, all CI checks green).
What changed
.vitepress/config.ts (the only file touched, +9/-10):
Added one top-level constant LAZY_MERMAID_CHUNK_NAMES next to HOSTNAME/SITEMAP_*, holding the chunk alternation. The chunk names now appear in exactly one place.
transformHtml uses LAZY_MERMAID_PRELOAD_LINK (a new RegExp built from the shared constant, g flag, same <link ... rel="modulepreload" ... /assets/chunks/...> wrapper), replacing the ~300-character inline literal.
resolveDependencies tests against LAZY_MERMAID_CHUNK_PATH ((?:^|/) wrapper) built from the same constant, replacing its second inline copy.
The two filters can no longer drift apart on Mermaid upgrades - add the name once, both regexes follow.
Verification
Regex parity is proven, not eyeballed: a script extracted the constructed patterns and compared them against the pre-change inline literals - byte-identical pattern source and flags (pathSourceMatch=true, linkSourceMatch=true).
bun run build exit 0; scanned all 42 built pages: zero modulepreload links for Mermaid, dagre, cytoscape or katex chunks, same as before.
Both old and new path filters agree on all 453 chunk-path tokens in the shipped JS/CSS assets.
bun run format:check, bun run lint:md, bun test (12/12) all pass; PR CI (Build, Lint, Docs drift, CodeQL, preview) green.
Roadmap board: issue moved to QA (goes to Done at merge). No docs ticket needed (no docs ticket: internal-only refactor in the PR body) and no downstream repo ripple effects - it is a behavior-preserving config refactor.
Skipped nothing functional; the one risk to know: I did not diff the full dist directory against a main build, I relied on the byte-identical-pattern proof plus the zero-lazy-preload scan across the freshly built output.
Activity
edenreich commentedon Nov 16, 2026
@infer can you work on this? use /ponytail:ponytail
inference-gateway-maintainer commentedon Nov 16, 2026
Model:
ollama_cloud/glm-5.3-flash· Action:v0.59.9· CLI:v0.262.0· Gateway:v0.67.1· View JobTodos
Pull Request
#1243
✅ Infer Result: Success
Done. Issue #1236 is resolved in PR #1243 (ready for review, all CI checks green).
What changed
.vitepress/config.ts(the only file touched, +9/-10):LAZY_MERMAID_CHUNK_NAMESnext toHOSTNAME/SITEMAP_*, holding the chunk alternation. The chunk names now appear in exactly one place.transformHtmlusesLAZY_MERMAID_PRELOAD_LINK(anew RegExpbuilt from the shared constant,gflag, same<link ... rel="modulepreload" ... /assets/chunks/...>wrapper), replacing the ~300-character inline literal.resolveDependenciestests againstLAZY_MERMAID_CHUNK_PATH((?:^|/)wrapper) built from the same constant, replacing its second inline copy.The two filters can no longer drift apart on Mermaid upgrades - add the name once, both regexes follow.
Verification
pathSourceMatch=true,linkSourceMatch=true).bun run buildexit 0; scanned all 42 built pages: zeromodulepreloadlinks for Mermaid, dagre, cytoscape or katex chunks, same as before.bun run format:check,bun run lint:md,bun test(12/12) all pass; PR CI (Build, Lint, Docs drift, CodeQL, preview) green.Roadmap board: issue moved to QA (goes to Done at merge). No docs ticket needed (
no docs ticket: internal-only refactorin the PR body) and no downstream repo ripple effects - it is a behavior-preserving config refactor.Skipped nothing functional; the one risk to know: I did not diff the full dist directory against a
mainbuild, I relied on the byte-identical-pattern proof plus the zero-lazy-preload scan across the freshly built output.Model:
ollama_cloud/glm-5.3-flash· Action:v0.59.9· CLI:v0.262.0· Gateway:v0.67.1· Exit Code:0· Duration: 5m 35sTokens: 1,822,513 in · 29,012 out · 1,851,525 total (36 requests)
Tool calls: 47 total · 100% success rate
Traces
Stats
Triggered by edenreich · Infer Action · OSS
inference-gateway-releaser commentedon Nov 17, 2026
🎉 This issue has been resolved in version 0.9.27 🎉
The release is available on GitHub release
Your semantic-release bot 📦🚀