Fork me on GitHub
#cljs-dev
<
2020-08-28
>
cfleming06:08:54

In Cursive, I call the analyser directly in order to generate function stubs for some namespaces that are hard to index via static analysis. I’m having problems doing this with helix, because it contains a require like: ["./impl/class.js" :as helix.class]. I’m getting an exception when analysing that: /_SLASH_impl_SLASH_class/js.cljs is not a relative path in file file:/Users/colin/.m2/repository/lilactown/helix/0.0.10/helix-0.0.10.jar!/helix/core.cljs. My analysis code looks like this (quasiquoted so a bit ugly, sorry):

(do
  (clojure.core/require (quote cljs.closure)
                        (quote cljs.env)
                        (quote cljs.analyzer.api)
                        (quote clojure.string)
                        (quote )
                        (quote clojure.walk))
  (clojure.core/let [opts4 (cljs.closure/add-implicit-options {:cache-analysis false})
                     state5 (cljs.env/default-compiler-env opts4)]
    (cljs.analyzer.api/analyze-file state5 "cljs/core.cljs" opts4)
    (cljs.analyzer.api/analyze-file state5 (clojure.core/or ( "helix/dom.cljs")
                                                            ( "helix/dom.cljc"))
                                    opts4)
Do I need to pass any options to the analyser to use node-style dependencies like that?

cfleming06:08:36

Actually, digging around a bit it looks like that relative path syntax might only be supported by Shadow, is that true @thheller?

thheller08:08:45

Yes, I added that as a simple way to include local JS that "just works". See https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js

cfleming08:08:46

Problem solved, that was indeed it.

scknkkrer21:08:29

Does ClojureScript encourage the unsatisfied arguments ? Like a function that takes argument and in the function body, it was just ignored when none given. It takes null/nil, and programming on this idea. Are we really OK with that ?

dominicm22:08:10

That's how JavaScript works. The compiler warns about this though.