fix: treeshaking#10504
Conversation
|
Using esbuild? I think most others can shake assigning class properties (it can have side effects, but usually does not). I'm not against changing to static properties, but its a breaking change. |
|
@kurkle webpack with terser (default minifier, actually terser make tree-shake). Why it's braking change ? Public API stays the same. |
|
Changing es version can break things. |
|
@kurkle we can add, for example, swc to transpilation |
|
my test bench: https://github.com/dangreen/chartjs-treeshaking-test |
swc and even babel transpile it to side-effected code 😕 |
|
|
@kurkle Ok, it's breaking change, but it's a desirable and valuable fix. So what is the release plan? |
|
I think this is one big thing to drive towards v4. I think we need to do 3.8.1 and 3.9 first. There has been some talk on moving to typescript in v4 (does not need to be full conversion IMO, just the transpilation stuff and some part as POC so things can be converted in steps). But this ts thing could pushed forward to v5 too. |
|
@kurkle Got it. Thank you! |
|
I'd be open to getting through 3.8.1 and 3.9 quickly so that we can start on v4 dev. |
|
Will review this evening my time. |
…dataElementType as static props
|
Personally, I have no objection to using static properties. They look to be fairly well supported and users can use something like Babel if they need to support older browsers. So I'd be in favor of this change |
etimberg
left a comment
There was a problem hiding this comment.
Overall looks good. Have one concern with the category scale change
|
We need to merge these in some sane order to avoid tough rebases |
I have the article about that 🙂 https://dev.to/cubejs/why-and-how-to-transpile-dependencies-of-your-javascript-application-3phf |
|
Going to merge this first, then #10525 can be rebased |
fixes #10163
Before (build of each export):
After:
Assign properties to classes is a side effect, so that's why tree-shaking didn't work. Changed it to static properties.
Also, some calls (class constructors) are marked as pure.
Also added size-limit to control sizes of specific exports. Action is failing cause it should be in the base branch to compare sizes.