fix(ui): lazy-load optional markdown peer deps to prevent import crashes - #210
Merged
Merged
Conversation
MarkdownRenderer now dynamically imports marked, highlight.js, and isomorphic-dompurify inside onMount instead of at module scope. This prevents consumers that haven't installed these optional peer deps from crashing when MarkdownRenderer is bundled but never rendered. Tests updated to use waitFor/waitForMarkdown for async rendering.
Deploying svadmin-example with
|
| Latest commit: |
77fb243
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://580057e7.svadmin-example.pages.dev |
| Branch Preview URL: | https://codex-fix-markdown-optional.svadmin-example.pages.dev |
Owner
Author
|
审查结论:暂不合并(FAIL)。 阻塞项:当前 head
因此 E2E 被跳过,尚无可接受的完成证据。请先修正类型/导入并让 CI 全绿。随后建议补一个最小消费者验收:不安装 Markdown 可选 peer,仅导入 Svelte autofixer另提示现有 |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MarkdownRendererstatically imports optional peer dependencies (marked,highlight.js,isomorphic-dompurify). When a consumer app hasn't installed these packages, the import crashes at module load time — even ifMarkdownRendereris never actually rendered.Solution
Convert the static imports to dynamic
import()calls insideonMount. The component now:marked,marked-highlight,highlight.js, andisomorphic-dompurifyasynchronously on mountonMountreturn functionTests
Updated
markdown-renderer.test.tsto usewaitFor/waitForMarkdownhelpers for async rendering. All 4 existing tests pass.