Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(web): allow the deferred infographic chunk past 500 KiB

tianma-ifc31dfe7a21d2
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts
index 4c24ca76..c0f372ec 100644
--- a/apps/web/vite.config.ts
+++ b/apps/web/vite.config.ts
@@ -284,7 +284,7 @@ export default defineConfig({
? false
: {
resolveDependencies: (_filename, dependencies) => dependencies.filter((dependency) =>
- !/(?:vendor-code-highlight|vendor-(?:mermaid|D3|tiptap|prosemirror|floating|codemirror|x6|zod)|vendor~(?:wasm|emacs-lisp)-|vendor-radix(?!-slot)|ui-primitives|ui-button-tooltip|i18n-ja-)/.test(dependency),
+ !/(?:vendor-code-highlight|vendor-(?:mermaid|D3|tiptap|prosemirror|floating|codemirror|x6|infographic|zod)|vendor~(?:wasm|emacs-lisp)-|vendor-radix(?!-slot)|ui-primitives|ui-button-tooltip|i18n-ja-)/.test(dependency),
),
},
rolldownOptions: {
@@ -342,7 +342,8 @@ export default defineConfig({
// AntV Infographic registers its template and shape catalogs through
// internal registries. Size-based splitting across chunks breaks
// initialization order, causing registry map lookups (e.g. .set)
- // to fail on undefined during chunk evaluation. Keep this graph atomic.
+ // to fail on undefined during chunk evaluation. Keep this graph
+ // atomic and leave the resulting chunk off the initial modulepreload.
},
{
name: "vendor-prosemirror",
diff --git a/scripts/verify-web-performance.mjs b/scripts/verify-web-performance.mjs
index 9546964b..6fef67a2 100644
--- a/scripts/verify-web-performance.mjs
+++ b/scripts/verify-web-performance.mjs
@@ -27,7 +27,7 @@ assert.deepEqual(
);
assert.doesNotMatch(serviceWorker, /edgeever-offline-shell/, "PWA must not retain a versioned offline HTML shell");
const modulePreloads = indexHtml.match(/<link rel="modulepreload"[^>]+>/g)?.join("\n") ?? "";
-const initialOptionalPattern = /vendor-code-highlight|vendor-D3|beautiful-mermaid|vendor-(?:mermaid|tiptap|prosemirror|floating|codemirror|x6)|vendor~(?:wasm|emacs-lisp)-|ui-primitives|mermaid\.core|[^"']*Diagram(?:EditorPane)?-/;
+const initialOptionalPattern = /vendor-code-highlight|vendor-D3|beautiful-mermaid|vendor-(?:mermaid|tiptap|prosemirror|floating|codemirror|x6|infographic)|vendor~(?:wasm|emacs-lisp)-|ui-primitives|mermaid\.core|[^"']*Diagram(?:EditorPane)?-/;
assert.doesNotMatch(modulePreloads, initialOptionalPattern, "Optional editor and diagram chunks must remain out of the initial HTML modulepreload list");
assert.doesNotMatch(modulePreloads, /ui-button-tooltip/, "Button tooltips must load only when a titled button is rendered");
assert.doesNotMatch(modulePreloads, /vendor-radix(?!-slot)/, "Radix overlays must remain out of the initial HTML modulepreload list");
@@ -39,9 +39,10 @@ assert.ok(initialModulePreloadBytes <= INITIAL_MODULE_PRELOAD_BUDGET, `Initial m
const DEFAULT_CHUNK_WARNING_BYTES = 500 * 1024;
// Shiki, loaded with the infographic conversation, keeps the Oniguruma wasm
-// engine and the Emacs Lisp grammar above 500 KiB. Both stay off the initial
-// modulepreload list.
-const allowedLargeChunkPattern = /^(?:vendor-(?:code-highlight|beautiful-mermaid|mermaid-(?:layout|render)|codemirror|x6)|vendor~(?:wasm|emacs-lisp)-|.*Diagram-).*\.js$/;
+// engine and the Emacs Lisp grammar above 500 KiB. AntV Infographic stays one
+// atomic deferred chunk so its registries initialize in order. All of these
+// stay off the initial modulepreload list.
+const allowedLargeChunkPattern = /^(?:vendor-(?:code-highlight|beautiful-mermaid|mermaid-(?:layout|render)|codemirror|x6|infographic)|vendor~(?:wasm|emacs-lisp)-|.*Diagram-).*\.js$/;
const largeChunks = readdirSync(join(distDirectory, "assets"))
.filter((name) => name.endsWith(".js"))
.map((name) => ({ name, size: statSync(join(distDirectory, "assets", name)).size }))