Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lazy import ledge render components #191

Open
LiuuY opened this issue May 6, 2020 · 0 comments
Open

lazy import ledge render components #191

LiuuY opened this issue May 6, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@LiuuY
Copy link
Collaborator

LiuuY commented May 6, 2020

现在 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 ...
@LiuuY LiuuY added the enhancement New feature or request label May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant