Closed mrginglymus closed 1 week ago
Thanks for your contribution! The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.
The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-20485@c939973
Congratulations! Your PR has been merged. Thanks for your contribution! 👍
Curious about why tslib 2.3.0 doesn't work.
I can not reproduce it with vite@6.0.0-beta.9. Could I have more info to reproduce it? @mrginglymus
What I've done is:
npm i -D vite@6.0.0-beta.9
npm i echarts
touch index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="./node_modules/echarts/dist/echarts.js"></script>
</head>
<body>
<p>good</p>
<div id="main" style="height: 500px; "></div>
<script>
var chart = echarts.init(document.getElementById('main'));
chart.setOption({
angleAxis: {
type: 'category',
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
},
tooltip: {},
radiusAxis: {},
polar: { center: ['40%', '50%'] },
series: [{
type: 'bar',
data: [1, 2, '-', 3, 0, 5, 7],
coordinateSystem: 'polar'
}]
});
chart.on('click', function (params) {
console.log(params);
});
</script>
</body>
</html>
npx vite
And the chart displayed normally.
@Ovilia @plainheart
Does this modification lead to breaking change? Or should we do full test against different version of tslib? or check every breaking changes of tslib since 2.3.0 to latest? Or should we make this change in a patch version if it might introduce breaking or error?
Honestly I didn't spend too much time on working out the why, only the what.
The error as spotted was this:
I will see if I can dig into what was wrong with vite here, as it may be worth an issue on their end as a regression.
Aside from compatibility in whatever obscure set of conditions I've discovered, the more significant benefit of this change is allowing users to ship only one copy of tslib; I currently use tslib@^2.5.0 to support decorators and whilst the size of tslib is insignificant compared to the echarts stack, it still bugs me to be shipping two copies.
Some memos:
__extends
function of tslib. (by searching from "tslib
in echarts/lib.).tsc -b && vite build
), only used functions of tslib will be included in bundle. That is only __extends
(and extendStatics
, which is called by __extends
internally) is included. So the bundle size is probably not a concern till now."tslib": "^x.x.x"
: Checked the commit log of __extends
on git, there's no breaking. Thus this change does not break echarts. tsc -b && vite build
) , the built bundle is like this :
// At the top scope of the bundle file dist/assets/index-JsGP8STl.js
// Two tslib are included but the name are modified to avoid conflict.
var extendStatics$1 = function(d, b) { /* ... */ };
function __extends$1(d, b) { /* ... */ }
/* ... */
var extendStatics = function(d, b) { /* ... */ };
function __extends(d, b) { /* ... */ }
Brief Information
This pull request is in the type of:
What does this PR do?
Relax dependency specifier of tslib
Fixed issues
Details
Before: What was the problem?
I was testing my library with vite v6.beta, and found that tslib@2.3.0 did not work; later version of tslib did work.
After: How does it behave after the fixing?
echarts now allows users to pick their own version of tslib - so a. it now works with vite v6 and b. users aren't unecessarily shipping two copies of tslib
Document Info
One of the following should be checked.
Misc
ZRender Changes
Related test cases or examples to use the new APIs
N.A.
Others
Merging options
Other information