cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
cfleming 2020-08-28T06:21:54.015100Z

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 <http://clojure.java.io|clojure.java.io>)
                        (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 (<http://clojure.java.io/resource|clojure.java.io/resource> "helix/dom.cljs")
                                                            (<http://clojure.java.io/resource|clojure.java.io/resource> "helix/dom.cljc"))
                                    opts4)
Do I need to pass any options to the analyser to use node-style dependencies like that?

cfleming 2020-08-28T06:25:36.015700Z

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

thheller 2020-08-28T08:42:45.016600Z

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

dominicm 2020-08-28T07:54:32.016Z

Yep!

cfleming 2020-08-28T08:26:46.016500Z

Problem solved, that was indeed it.

scknkkrer 2020-08-28T21:37:29.019100Z

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 ?

dominicm 2020-08-28T22:27:10.019700Z

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