I forgot to mention that I derived the above by following the React instructions for create-react-app (https://canvasjs.com/docs/charts/integration/react/), then doing a “yarn eject” to see the loader it was using in webpack. I had to trial-and-error my way through the correct path, presets, and plugins that made it work with the rest of my project.
I found I needed to fiddle with my Webpack config a bit to get something working. In case it helps somebody else, this is what worked for my React app…
1. Copied canvasjs.min.js and canvasjs.react.js to a new folder at the root called “assets” 2. Installed some babel stuff “npm install –save-dev babel-loader @babel/core @babel/preset-env @babel/preset-react @babel/plugin-proposal-class-properties” 3. Modified my webpack.config.js to use babel to load canvasJS files ` { test: /\.js$/, include: [ path.resolve(__dirname, ‘assets’), ], use: { loader: ‘babel-loader’, options: { presets: [ [‘@babel/preset-env’, { targets: “defaults” }], “@babel/preset-react” ], “plugins”: [ “@babel/plugin-proposal-class-properties” ] } } }, `
I’m not entirely sure all of the babel setting are correct or necessary, but I found it to work via trial-and-error so I’m likely to keep it as-is. I hope this helps.