Chart.js
Chart.js copied to clipboard
[Bug]: Error Thrown on Next Build
Expected behavior
Chart.Js should work on Next Build
Current behavior
With NextJS, the library works well on development. But an error is thrown after running the app after building it.
RangeError: minimumFractionDigits is out of range
I'm using also the react-chartjs-2.
I opened an issue on react-chartjs-2 repo, but then have been told the error comes from the chartjs library itself.
Reproducible sample
https://github.com/LouisJackson/react-chart-test
Optional extra steps/info to reproduce
No response
Possible solution
No response
Context
No response
chart.js version
v3.9.1
Browser name and version
No response
Link to your project
No response
Seems that during production in this line https://github.com/chartjs/Chart.js/blob/d4e106cc9cf19a273e5485ffaf6158f663e65717/src/helpers/helpers.intl.js#L4
The minimumFractionDigits and maximumFractionDigits in the options become NaN instead of 0.
Issue might be related to #10672
Indeed same issue as #10672
swcMinify: false
in next.config.js makes it work.
It looks like this is out of our control and you need to use the option @kurkle pointed out, when debugging al the numbers are correctly but it fails on line 105, that will give a NaN
.
https://github.com/chartjs/Chart.js/blob/e7372ade240ea67769ed218cd420129bac403dfa/src/scales/scale.linearbase.js#L104-L105
If I put a console log between line 104 and 105 it does work so it does seem like this is out of our control
So it seems like its not something we can do anything about
swcMinify: false
in next.config.js makes it work.
Paljon Kiitoksia / Thanks a lot @kurkle, this fixed the bug
Any information on when the next version release will be?
this should be fixed in next-swc, not in chart.js So this issue should be created there instead.
Hi everyone, I reported this issue in the swcMinify
feedback discussion here:
https://github.com/vercel/next.js/discussions/30237#discussioncomment-3717121
referencing this issue with sample repo from @LouisJackson
swcMinify: false
in next.config.js makes it work.
Thank you
Closing this as it is not a chart.js issue but a swc minifier issue instead
swcMinify: false
in next.config.js makes it work
Thank you!
swcMinify: false
Why do we do it like this?