Using ECHarts Tree Shaking API's not reducing the overall package size of an Angular application
See original GitHub issueVersion
5.0.1
Steps to reproduce
We compared using full echarts against echarts tree shakable API’s.
Option 1: Full ECharts imported
var echarts = require('echarts');
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;
option ={
title: {
text: '饼图程序调用高亮示例',
left: 'center'
},
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
legend: {
orient: 'vertical',
left: 'left',
data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
},
series: [
{
name: '访问来源',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: [
{value: 335, name: '直接访问'},
{value: 310, name: '邮件营销'},
{value: 234, name: '联盟广告'},
{value: 135, name: '视频广告'},
{value: 1548, name: '搜索引擎'}
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}]
};
option && myChart.setOption(option);
Our observation is this:
Total Main.js Size: 1.2 MB
Option 2: Using tree shakable API’s from ECharts
import * as echarts from 'echarts/core';
import {
PieChart
} from 'echarts/charts';
import {
TitleComponent,
TooltipComponent,
GridComponent
} from 'echarts/components';
import {
SVGRenderer
} from 'echarts/renderers';
echarts.use(
[TitleComponent, TooltipComponent, GridComponent, PieChart, SVGRenderer]
);
Observation
Total Main.js Size: 1.3 MB
What is expected?
We should get a reduced overall package size when tree shakable API is introduced.
What is actually happening?
So as you could see total size of main.js increased with tree shakable API usage. What could be the reason for the increase in package size after using tree shakable API?
Please let us know in case the approach we followed is not correct.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Using ECHarts Tree Shaking API's not reducing the overall ...
[GitHub] [echarts] msbasanth commented on issue #15138: Using ECHarts Tree Shaking API's not reducing the overall package size of an Angular ...
Read more >How to decrease prod bundle size? - angular - Stack Overflow
Firstly, vendor bundles are huge simply because Angular 2 relies on a lot of libraries. Minimum size for Angular 2 app is around...
Read more >Changelog - Apache ECharts
#16772 (jiawulin001); [Fix] [tree] fix radial tree with a single root not working. ... which enabled tree shaking of bundle and reduced size....
Read more >Reduce JavaScript payloads with tree shaking - web.dev
Knowing where to begin optimizing your application's JavaScript can be daunting. If you're taking advantage of modern tooling such as webpack, however, tree...
Read more >Honey, I shrunk the bundle — A story about Angular ... - Medium
One main problem we were facing was the bundle size and the overall performance of the application in the browser. It felt non-responsive...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@msbasanth It seems you are not using English, I’ve helped translate the content automatically. To make your issue understood by more people, we’d like to suggest using English next time. 🤗
TRANSLATED
BODY
Version
5.0.1
Steps to reproduce
We compared using full echarts against echarts tree shakable API’s.
Option 1: Full ECharts imported
Our observation is this:
Total Main.js Size: 1.2 MB
Option 2: Using tree shakable API’s from ECharts
Observation
Total Main.js Size: 1.3 MB
What is expected?
We should get a reduced overall package size when tree shakable API is introduced.
What is actually happening?
So as you could see total size of main.js increased with tree shakable API usage. What could be the reason for the increase in package size after using tree shakable API?
Please let us know in case the approach we followed is not correct.
@pissang Thanks for the solution given. As suggested registered theme by passing the json theme data
echarts.registerTheme('dark',theme)
. Observation I could see reduction, now main.js size of the angular application is 687KB. Base Angular main.js size is 140KB, that means approx. 540KB added by echarts. So it looks like tree shaking is working as documented. Hope this is the reduction I can expect.