reactchartjs/react-chartjs-2

[Bug]: latest react-chart-js2 5.2.0 doesn't work with storybook

psnb88 opened this issue · 4 comments

Would you like to work on a fix?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

Current and expected behavior

Usage:- I use storybook( 6.5.13, webpack 4.6.4) ,react (react-scripts :5.0.1), react-chart-js2(5.2.0) ,chart.js(4.2.1) in my project.

Current behaviour :- npm run storybook throws exception " ERROR in ./node_modules/chart.js/dist/chart.js 568:17
Module parse failed: Unexpected token (568: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;

Expected : storybooking react chart.js components should work.

Reproduction

NA

chart.js version

4.2.1

react-chartjs-2 version

5.2.0

Possible solution

Workaround tried:-

  • downgrading chartjs to 2.9.4 seems to work.
  • excluding files and folder which had reference to react-chart-js2 didn't work. code used for excluding filesand folder is below

webpackFinal: async (config, {configType}) => {
config.module.rules.push({
test: /.js$/,
exclude: [
path.resolve(__dirname, '../path/'),
,
],
});
return config;
},

Works on my machine, Running 5.2.0 / 4.3.0

I'm having the same issue, any progress on this?

Same config as OP, same error here

same here