[Refactor/Chore] Lazy-load ECharts and ABC music renderers by Markdown code-block language

オープン
#42,436 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
react, typescript

調査の方向性

Start with web/app/components/base/markdown-blocks/code-block.tsx and music.tsx, then inspect the Markdown wrapper's existing dynamic loading. Verify plain, echarts, and abc fences in development and production, including streaming, theme/resize, audio, and error behavior; update focused tests and record before/after bundle evidence.

索引モデルが issue の本文から書いたものです。

説明

project#dify
Self Checks
  • I have read the Contributing Guide and Language Policy.
  • This is only for refactors or chores; questions belong in Discussions.
  • I have searched for existing issues, including closed ones.
  • I confirm that I am using English to submit this report.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • I have filled in the required template fields.
Description

web/app/components/base/markdown-blocks/code-block.tsx statically imports echarts-for-react and music.tsx. web/app/components/base/markdown-blocks/music.tsx statically imports abcjs and its audio CSS.

The outer code-block component is already dynamically loaded by the Markdown wrapper. However, loading it for an ordinary code fence also brings in the special chart/music renderers, even when the content contains no echarts or abc fence.

Local build evidence:

Chunk Uncompressed Estimated gzip
ECharts shared chunk (ECharts, zrender, React adapter) 1,132,306 B 371,226 B
code-block chunk (includes 152 abcjs modules plus other functionality) 719,834 B 211,585 B

Load the specialized renderer when its corresponding language is rendered, with suitable loading/error behavior. Keep the full ECharts capabilities needed by user-provided chart options; trimming chart registrations is a separate compatibility decision.

Motivation

Plain code fences should not require chart and music runtimes. The static dependency closure of the code-block boundary is currently approximately 3.41 MB (1.05 MB gzip), including shared dependencies; this is not a page first-load measurement.

Acceptance criteria:

  • In an isolated plain-code-block scenario, no ECharts or abcjs runtime is loaded solely because the generic code-block component is rendered.
  • echarts and abc fences load their respective renderer on demand and still support streaming updates, theme/resize behavior, audio controls and error handling.
  • Verify both development and production loading behavior and update focused tests.
  • Provide before/after bundle evidence. Other chart-consuming pages can still load shared chart chunks independently.
Additional Context

Measurements come from a local Dify 1.17.1 development checkout (base commit 06e473015a9a1abb71da88ac0a0e92d96a992008, with local DevTools integration patches), using Vinext 1.0.0-beta.10 / Vite+ core 0.3.2 / Node 24.21.0. They are a diagnostic baseline, not a benchmark of an unmodified main checkout or a production network measurement. Related background: #30931 (closed).

Static dependency totals below follow manifest imports recursively, deduplicate files, and exclude dynamic imports, CSS, images and fonts. Gzip values are summed per-file estimates. Shared closures overlap and must not be added together.

主要言語
TypeScript
スター
157k
フォーク
24.7k
平均マージ
22時間 32分
マージ済み PR(30日)
611

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

langgenius/dify のほかの issue

langgenius/dify の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。