Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include external javascript libraries in clojurescript

We are trying to introduce clojurescript in a project which is currently written in angularjs. We are using an external javascript library - datamaps. We are using the :foreign-libs compiler option to get the dependency file in the following manner :

 :compiler {:output-to "resources/public/js/testable.js"                                                                       
                              :main "gofigure.test-runner"                                                                                       
                              :foreign-libs [{:file "globe.js"                                                                                   
                                              :provides ["globe"]}                                                                               
                                             {:file "datamaps/src/js/datamaps.js"                                                                
                                              :provides ["datamaps"]}                                                                            
                                             {:file "d3/d3.js"                                                                                   
                                              :provides ["d3"]}                                                                                  
                                             {:file "topojson/topojson.js"                                                                       
                                              :provides ["topojson"]}}}

We are facing an error that says : "Cannot read property 'world' of undefined"

We narrowed this issue down to an issue in the datamaps file and we think this is because in the foreign-libs option we are mentioning the specific datamaps.js file, but we are missing out the other files in the datamaps folder, and hence not compiling the entire library accurately.

Is there any way to include the entire library as a dependency and not just a single file?

like image 948
Kusum Ijari Avatar asked Nov 09 '22 00:11

Kusum Ijari


1 Answers

Shadow-cljs could resolve this issue.

Shadow-cljs solves these probems reliably, optimally, and with minimal configuration. In paricular, shadow-cljs lets you install npm modules using npm or yarn and uses the resulting package.json to bundle external dependencies.

For further details https://gist.github.com/jmlsf/f41b46c43a31224f46a41b361356f04d

like image 133
TAB Avatar answered Nov 14 '22 21:11

TAB