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

treeshaking not working as expected #433

Open
mchl18 opened this issue Nov 7, 2024 · 2 comments
Open

treeshaking not working as expected #433

mchl18 opened this issue Nov 7, 2024 · 2 comments

Comments

@mchl18
Copy link

mchl18 commented Nov 7, 2024

hi guys,

I wanted to use the instructions to use tree shaking and then did an analysis of the bundle.

See for yourself

image

thats a total of 6mb for rendering three different kinds of charts. don't think that's the way it was intended. echarts show up twice, once in the vendor module where it seems like everything gets pulled in and once outside of it.

here is. my config (./config/echarts-config.ts)

import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  LegendComponent,
} from 'echarts/components';
import { BarChart, LineChart, PieChart } from 'echarts/charts';
import { LabelLayout, UniversalTransition } from 'echarts/features';
import { CanvasRenderer } from 'echarts/renderers';
import 'echarts/theme/macarons.js';
import * as echarts from 'echarts/core';

// Register the required components
echarts.use([
  BarChart,
  LineChart,
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  LabelLayout,
  UniversalTransition,
  CanvasRenderer,
  LegendComponent,
  PieChart,
]);

export { echarts };

then in my app.module.ts

import { echarts } from './config/echarts-config';
import { NgxEchartsDirective, provideEchartsCore } from 'ngx-echarts';
....
 imports: [
    NgxEchartsDirective
 ],
 providers: [
    provideEchartsCore({ echarts })
 ],

please let me know if you can reproduce this.

@mchl18
Copy link
Author

mchl18 commented Nov 7, 2024

found out sth.

this line

import 'echarts/theme/macarons.js'

appears to make a difference.

image

I am honestly not sure what is going on, I created a new fresh angular repo where I imported the exact same code but there I only got a couple hundred kb as expected, whereas this angular/ionic repo we are working on spits out the whole echarts dep when using this palette.

@achraf-codemaster
Copy link

Same issue 426 (5 months ago)
not solved yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants