Skip to content

Commit 82f9798

Browse files
authored
perf: Self-host mermaid and load it only on pages with diagrams (#902)
* perf: Self-host mermaid and load it only on pages with diagrams Every page used to import mermaid (~2 MB of js) from cdn.jsdelivr.net whether it contained a diagram or not. The mermaid-script partial now checks for a .mermaid element and only then imports a self-hosted es module build; mermaid's internal chunks lazy-load per diagram type. The extension skips injecting its own script when the UI ships partials/mermaid-script.hbs, so the mermaid_library_url/script_stem playbook configuration is gone and no third-party CDN is involved. * fix: Ship mermaid's own es-module dist instead of re-bundling it mermaid is a prebuilt, minified package; running another bundler over it produced 'undefined is not a function' at runtime. The build now copies the dist entry and its transitive chunk imports verbatim - the same artifact the CDN used to serve. The import closure is verified complete at build time by construction (every referenced chunk is copied), and the module graph import-checks cleanly under node.
1 parent f19129f commit 82f9798

10 files changed

Lines changed: 1685 additions & 239 deletions

antora-playbook.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ urls:
2828
antora:
2929
extensions:
3030
- require: '@sntke/antora-mermaid-extension'
31-
mermaid_library_url: https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs
32-
script_stem: mermaid-scripts
3331
- ./lib/stackable-operator-helpers.js
3432
- ./lib/llms-txt.js
3533
content:

local-antora-playbook.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ urls:
1313
antora:
1414
extensions:
1515
- require: '@sntke/antora-mermaid-extension'
16-
mermaid_library_url: https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs
17-
script_stem: mermaid-scripts
1816
- ./lib/stackable-operator-helpers.js
1917
- ./lib/llms-txt.js
2018
content:

only-dev-antora-playbook.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ urls:
1313
antora:
1414
extensions:
1515
- require: '@sntke/antora-mermaid-extension'
16-
mermaid_library_url: https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs
17-
script_stem: mermaid-scripts
1816
- ./lib/stackable-operator-helpers.js
1917
- ./lib/llms-txt.js
2018
content:

0 commit comments

Comments
 (0)