Fork me on GitHub
#shadow-cljs
<
2021-03-27
>
lispers-anonymous04:03:24

I'm having issues using the vega-embed library from npm with shadow-cljs that I would like some help with. I will put all the details of my problem in a thread so it doesn't get too noisy.

duckie 2
lispers-anonymous04:03:26

In my package.json I have the following dependencies declared

"dependencies": {
    ...
    "vega": "5.20.0",
    "vega-embed": "6.17.0",
    "vega-lite": "5.0.0"
	...
}
When the application starts up, these warnings show up in the browser console as soon as the application loads.
shadow-cljs - failed to load module$node_modules$d3_array$dist$d3_array js.js:74:16
shadow-cljs - failed to load module$node_modules$vega_format$build$vega_format js.js:74:16
shadow-cljs - failed to load module$node_modules$vega_loader$build$vega_loader js.js:74:16
shadow-cljs - failed to load module$node_modules$vega_dataflow$build$vega_dataflow js.js:74:16
shadow-cljs - failed to load module$node_modules$vega$build$vega_node js.js:74:16
shadow-cljs - failed to load module$node_modules$vega_embed$build$vega_embed
In my cljs code, I'm attempting to use the vega library like this.
(ns components.charts.vega-chart
  (:require
    ;; ...
    ["vega-embed" :as vega-embed]))
	
;; later in the namespace
(vega-embed/embed node spec options)
The value of vega-embed is an empty javascript object. The problem seems to be occuring before I even get to exectue this code. If I evaluate any of my cljs code that makes use of vega-embed I get a bunch of errors that all trace back to the vega code not being loaded (nils, not a function, etc) Would anyone be able to help me get to the bottom of this?

lispers-anonymous04:03:07

Damn. Everytime I sit down and write up a big question for slack I find a solution right after. Adding :output-feature-set :es6 to my shadow-cljs :compiler-options map fixed this for me. I got the idea from this post https://stackoverflow.com/questions/64461818/require-aws-amplify-v-3-amplify-and-auth-classes-in-clojurescript-reagent-shadow