chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
64.83k stars 11.92k forks source link

Module parse failed: Unexpected token (567:17) #11375

Open romanown opened 1 year ago

romanown commented 1 year ago

Expected behavior

i create test app on codepen it work. but localy on symfony i have error

Current behavior

after first install by npm and run watch an symfony i have Module parse failed: Unexpected token (567:17) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. class DatasetController {

static defaults = {}; | static datasetElementType = null; | static dataElementType = null;

Reproducible sample

can not

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

4.3.0

Browser name and version

No response

Link to your project

No response

AndreasZaschka commented 1 year ago

Same for Angular Setup with Nx and Cypress

Module parse failed: Unexpected token (567:17)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     };
| class DatasetController {
>  static defaults = {};
|  static datasetElementType = null;
|  static dataElementType = null;
romanown commented 1 year ago

I temporarily solved the problem by downgrading the version to 3.9.1. I hope the developers will soon pay attention to this problem and fix it.

etimberg commented 1 year ago

@romanown the code that we have is valid JavaScript. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static

I think you need to configure Webpack/Babel per https://stackoverflow.com/questions/64928312/webpack-static-field

romanown commented 1 year ago

thnks. i use the Symfony and can not configure thw webpack separately

romanown commented 1 year ago

before I installed this library, everything worked fine. the problem is in this library or in its compatibility, or a newer version of the webpack or babel is needed

VenkataSuresh7989 commented 1 year ago

Currently, I'm using chart.js 3.9.1.I want to upgrade the version 4.3.0 for new features. Getting below error while updating 4.3.0 then run the vue2 project. (https://i.stack.imgur.com/fZHs1.png).Give me proper solution.

sklinov commented 1 year ago

Same for React: 17 Chart.js: 4.4.0 webpack: 4.46.0

itokun99 commented 10 months ago

any update? still issue in react 18, chartjs v4, in cra

icleolion commented 7 months ago

For those of you in a position to change your webpack/babel config you'll need to ensure chart.js is pushed through babel-loader and that you are using @babel/plugin-transform-class-properties, either directly or via @babel/preset-env.

romanown commented 7 months ago

thanks. i use symfony encore with "@babel/plugin-proposal-class-properties": "^7.17.12", "@babel/preset-react": "^7.17.12",