Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

[Bug]: Error Thrown on Next Build

Open LouisJackson opened this issue 2 years ago • 4 comments

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

LouisJackson avatar Sep 15 '22 13:09 LouisJackson

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

LeeLenaleee avatar Sep 15 '22 19:09 LeeLenaleee

Indeed same issue as #10672 image

LeeLenaleee avatar Sep 15 '22 19:09 LeeLenaleee

swcMinify: false in next.config.js makes it work.

kurkle avatar Sep 15 '22 19:09 kurkle

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

LeeLenaleee avatar Sep 15 '22 20:09 LeeLenaleee

swcMinify: false in next.config.js makes it work.

Paljon Kiitoksia / Thanks a lot @kurkle, this fixed the bug

ArturAronov avatar Sep 17 '22 17:09 ArturAronov

Any information on when the next version release will be?

saifbechan avatar Sep 22 '22 11:09 saifbechan

this should be fixed in next-swc, not in chart.js So this issue should be created there instead.

imranbarbhuiya avatar Sep 22 '22 12:09 imranbarbhuiya

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

indralukmana avatar Sep 23 '22 12:09 indralukmana

swcMinify: false in next.config.js makes it work.

Thank you

aimdexter avatar Sep 23 '22 17:09 aimdexter

Closing this as it is not a chart.js issue but a swc minifier issue instead

LeeLenaleee avatar Sep 24 '22 21:09 LeeLenaleee

swcMinify: false in next.config.js makes it work

Thank you!

park-siwan avatar Oct 12 '22 06:10 park-siwan

swcMinify: false

Why do we do it like this?

rukundo-joe avatar Oct 25 '23 12:10 rukundo-joe