I’m looking for help with a Clojurescript / figwheel.main / webpack / highcharts issue. I’ve upgraded from highcharts 11 to 12. They’ve changed the way imports work - see https://www.highcharts.com/docs/getting-started/version-12 Previously, the following worked:
(ns my-project.core
(:require
["highcharts" :as Highcharts]
["highcharts/modules/heatmap" :as Heatmap]))
;; initialize the heatmap module
(Heatmap Highcharts)
However since the upgrade, apparently the initialization is done ‘automatically’, but I don’t know enough how webpack works enough to understand what that means and what needs to change. Practically it means I get an error that seems to signify something didn’t load properly.
heatmap.js:9 Uncaught TypeError: Cannot read properties of undefined (reading 'Axis')
at eval (heatmap.js:9:69)
at eval (heatmap.js:9:204)
at ./node_modules/highcharts/modules/heatmap.js (main_bundle.js:8380:1)
at __webpack_require__ (main_bundle.js:10290:42)
at eval (npm_deps.js:3:35)
I’m using figwheel.main 2.20 and cljs version 1.12.134.
Any pointers would be so welcome, I’ve been banging my head against a wall (figuratively) for about a day now… it’s squarely in the domain of things I know I don’t know, but don’t know how to find clear information about.Switching to shadow-cljs from figwheel.main seems to have fixed the problem, but I’m none the wiser
I have never used highcharts, but my guess is that you are mixing es modules and commonjs files. the highcharts package ships both and my guess for ["highcharts" :as Highcharts] webpack picks the esm module, but ["highcharts/modules/heatmap" :as Heatmap] refers to a commonjs file
shadow-cljs on the other hand picks commonjs as the default, so both are commonjs and therefore fine
or your webpack config is just broken somehow. no clue, just guessing
there are some files in the es-modules folder in the package. dunno what they are for, but based my guess on that
ah thanks that makes sense that it's a problem of mixing two sorts of modules. I didn't have a webpack config at all, just relied on whatever figwheel did there sounds like I might need to read up on that. I appreciate the pointers @thheller !