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

Chart.js v4 onwards, Missing Class properties transform

Open chenjsfrost opened this issue 1 year ago • 2 comments

Expected behavior

Running with React v17, react-chartjs-2 v5.2.0. It should start up the application as used in Chart.js v3

Current behavior

Unable to start application, error prompted Missing class properties transform in node_modules\chart.js\dist\chart.js, line 568 "static defaults = {};"

Reproducible sample

Optional extra steps/info to reproduce

Just npm i chart.js v4 onwards and run the application

Possible solution

No response

Context

No response

chart.js version

v4.1 , v4.4

Browser name and version

Chrome, v117

Link to your project

No response

chenjsfrost avatar Oct 03 '23 03:10 chenjsfrost

This is valid javascript. It might be that you are transpiling it to a lower version which does not understand this. Adding @babel/plugin-proposal-class-properties should resolve this: https://stackoverflow.com/questions/35517245/error-missing-class-properties-transform

LeeLenaleee avatar Oct 20 '23 13:10 LeeLenaleee

@LeeLenaleee Hello, I'm glad to see your answer but I'm confusing as I know, by default, @babel/plugin-proposal-class-properties only support code in src, it is not auto-transform code in node_modules What do you mean when you suggest we use that package to fix this issue? and another question, why chart.js do not transpile whole code? why it still keep some static in the built code

yanghoxom avatar Jan 09 '24 09:01 yanghoxom

I am having the same problem and @LeeLenaleee is not a solution.

rehovicova avatar Mar 13 '24 20:03 rehovicova

I had the same problem when running on node v14.21.3, but not when on v18.14.1.

yukon-zim avatar Mar 21 '24 21:03 yukon-zim