refactor: harden mobile editing and PWA caching
This commit is contained in:
1 parent
c9f2c0f6a2
commit
30f47dac4c
11 files changed
+742
-589
No files matched your search
@@ -23,9 +23,17 @@ assert.doesNotMatch(precacheManifest, /\{url:"index\.html",/, "Current HTML must
|
||||
assert.match(precacheManifest, /index\.html\?edgeever-offline-shell=/, "PWA must retain a versioned offline HTML shell");
|
||||
const optionalDiagramPattern = /(?:beautiful-mermaid|vendor-mermaid|mermaid\.core|[^"']*Diagram-)[^"']*\.js/;
|
||||
assert.doesNotMatch(precacheManifest, optionalDiagramPattern, "Optional diagram chunks must remain out of the initial PWA precache");
|
||||
assert.doesNotMatch(precacheManifest, /noto-sans-sc-[^"']*\.woff2/, "Print-only Noto Sans SC shards must remain out of the PWA precache");
|
||||
|
||||
const entryCount = (precacheManifest.match(/\{url:/g) ?? []).length;
|
||||
const precacheURLs = [...precacheManifest.matchAll(/\{url:"([^"]+)"/g)].map((match) => match[1]);
|
||||
const entryCount = precacheURLs.length;
|
||||
assert.ok(entryCount > 0, "Web service worker precache manifest must not be empty");
|
||||
const precacheBytes = precacheURLs
|
||||
.filter((url) => !url.startsWith("/") && !url.includes("?"))
|
||||
.map((url) => statSync(join(distDirectory, url)).size)
|
||||
.reduce((total, size) => total + size, 0);
|
||||
const PRECACHE_BUDGET = 5 * 1024 * 1024;
|
||||
assert.ok(precacheBytes <= PRECACHE_BUDGET, `PWA precache budget exceeded: ${precacheBytes} > ${PRECACHE_BUDGET}`);
|
||||
const modulePreloads = indexHtml.match(/<link rel="modulepreload"[^>]+>/g)?.join("\n") ?? "";
|
||||
const initialOptionalPattern = /vendor-code-highlight|vendor-D3|beautiful-mermaid|vendor-(?:mermaid|tiptap|prosemirror|floating)|ui-primitives|mermaid\.core|[^"']*Diagram-/;
|
||||
assert.doesNotMatch(modulePreloads, initialOptionalPattern, "Optional editor and diagram chunks must remain out of the initial HTML modulepreload list");
|
||||
@@ -60,6 +68,8 @@ assert.ok(
|
||||
console.log(JSON.stringify({
|
||||
ok: true,
|
||||
precacheEntries: entryCount,
|
||||
precacheBytes,
|
||||
precacheBudget: PRECACHE_BUDGET,
|
||||
initialModulePreloadBytes,
|
||||
initialModulePreloadBudget: INITIAL_MODULE_PRELOAD_BUDGET,
|
||||
largeDeferredChunks: largeChunks,
|
||||
|
||||
Reference in new issue
Block a user