Skip to content

lazy import ledge render components #191

Description

@LiuuY

现在 Ledge render 的 component 是写死在代码里面的,例如:

switch (codeBlock.lang) {
    case 'chart':
        const chartData = LedgeMarkdownConverter.toJson(codeBlock.text);
        this.markdownData.push({ type: 'chart', data: chartData.tables[0] });
        break;
    case ...

可能导致并没有使用的 component 包含进来。

可以改为 lazy import 的方式

switch (codeBlock.lang) {
    case 'chart':
        import('./chart/ledge-bar-chart/ledge-bar-chart.component').then(({ LedgeBarChartComponent }) => {
          const componentFactory = this.componentFactoryResolver.resolveComponentFactory(LedgeBarChartComponent);
          const { instance } = this.chartContainer.createComponent(componentFactory);

          instance.data = chartData.tables[0]
        });
    case ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions