5

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?

3
  • like adding the whole folder at one go? Or getting the dependencies to download for you? Commented Mar 14, 2017 at 12:01
  • 1
    @Mrinal We have a bower file which will download the dependencies such that they are available in the file structure but we are not able to access these files through our clojurescript code. Commented Mar 14, 2017 at 12:10
  • 2
    Most popular JS libraries are available on cljsjs.github.io. The benefit of using those libraries is that they are loaded when you require them in the ns declaration. Also they are provided with externs, so advanced compilation works. It might be worth the effort contributing this library, so this problem is solved for everyone. Commented Mar 14, 2017 at 21:52

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.