fix(ui): fix chapter page SSR crash by lazy-loading marked

Static import of 'marked' was included in the SSR bundle causing
ERR_MODULE_NOT_FOUND on first server render. The import is only
ever used inside onMount (client-only fallback path), so replace
with a dynamic import() at the call site.
This commit is contained in:
Admin
2026-03-10 18:20:35 +05:00
parent c7b3495a23
commit 4f82f659da

View File

@@ -2,7 +2,6 @@
import { onMount } from 'svelte';
import AudioPlayer from '$lib/components/AudioPlayer.svelte';
import type { PageData } from './$types';
import { marked } from 'marked';
let { data }: { data: PageData } = $props();
@@ -42,6 +41,7 @@
if (!res.ok) throw new Error(`status ${res.status}`);
const d = (await res.json()) as { text?: string };
if (d.text) {
const { marked } = await import('marked');
html = await marked(d.text, { async: true });
} else {
fetchError = 'Chapter content not available.';