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

Module parse failed: Unexpected token (567:17)

Open romanown opened this issue 1 year ago • 7 comments

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

romanown avatar Jun 28 '23 22:06 romanown

Same for Angular Setup with Nx and Cypress

  • Angular 16.x.x
  • Nx 16.x.x
  • Cypress 12.16.0
  • Chartjs 4.3.0
  • webpack 5.x.x
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;

AndreasZaschka avatar Jul 04 '23 07:07 AndreasZaschka

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.

romanown avatar Jul 04 '23 08:07 romanown

@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

etimberg avatar Jul 04 '23 13:07 etimberg

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

romanown avatar Jul 04 '23 19:07 romanown

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

romanown avatar Jul 04 '23 19:07 romanown

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.

VenkataSuresh7989 avatar Jul 21 '23 02:07 VenkataSuresh7989

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

sklinov avatar Oct 25 '23 12:10 sklinov

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

itokun99 avatar Jan 19 '24 12:01 itokun99

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.

icleolion avatar Apr 17 '24 10:04 icleolion

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

romanown avatar Apr 18 '24 21:04 romanown