helix

https://github.com/Lokeh/helix
cfleming 2020-08-28T02:40:11.016800Z

Hi everyone, I’m trying to implement support for helix in Cursive, per: https://github.com/cursive-ide/cursive/issues/2330. When Cursive analyses helix.core, I’m getting an error: /_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. Has anyone seen this error, or have any idea what it might mean? It’s coming from deep inside some generated code, but as far as I can tell the generated code should be good and I haven’t had problems like this analysing other CLJS projects.

cfleming 2020-08-28T02:42:07.017500Z

Oh wait, it looks like the problem might be with ["./impl/class.js" :as helix.class], although I have no idea what that problem might be.

lilactown 2020-08-28T04:00:35.018Z

hmm what are you using to analyze the project?

cfleming 2020-08-28T06:15:17.018700Z

I’m using the analyser directly, it looks like this:

(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)

cfleming 2020-08-28T06:15:33.019100Z

(this is quasiquoted so a bit ugly, sorry)

cfleming 2020-08-28T06:16:06.019700Z

Do I need to pass any options to the analyser to use node-style interop forms?

cfleming 2020-08-28T06:16:34.020400Z

I’ll ask this over in #cljs-dev too.

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

@cfleming 0.0.10 had shadow specific code in it. That line doesn't work with the clojurescript analyzer. That's now fixed in a newer version and it works with clojurescript analyzer.

cfleming 2020-08-28T08:25:48.024300Z

Thanks @dominicm, upgrading to 0.0.13 fixes that. I now get another error: No such namespace: react, could not locate react.cljs, react.cljc, or JavaScript source providing "react" in file file:/Users/colin/.m2/repository/lilactown/helix/0.0.13/helix-0.0.13.jar!/helix/core.cljs. Any idea what that might be about? This is with helix-todo-mvc, but with the helix dep upgraded as above. React is installed in node_modules but I can’t see anything react-related in the CLJS deps.

cfleming 2020-08-28T08:29:08.024900Z

The analyser code above is executed in a process with the CWD set to the project root.

dominicm 2020-08-28T08:40:27.025400Z

@cfleming clojurescript should search the node_modules directly for react, so I'm not sure why it wouldn't pick it up.

cfleming 2020-08-28T08:40:48.025700Z

Does the analyzer need an option passed to it to do that?

dominicm 2020-08-28T08:47:50.026200Z

Maybe :npm-deps true, but I thought it was default.

cfleming 2020-08-28T08:48:09.026500Z

Yeah, I just tried that and adding it doesn’t help.

dominicm 2020-08-28T08:48:34.026800Z

I don't suppose your cljs version is really old? 😄

cfleming 2020-08-28T08:49:03.027200Z

Hehe, well, it uses whatever helix-todo-mvc is using.

dominicm 2020-08-28T08:49:24.027600Z

https://clojurescript.org/reference/compiler-options#npm-deps looks like :npm-deps true is necessary.

dominicm 2020-08-28T08:51:19.028100Z

https://github.com/lilactown/helix-todo-mvc/blob/master/deps.edn there's no dependency on clojurescript, so it might be that you're trying to use the cljs analyzer, and this project uses shadow. But I don't know anything about that tbh.

cfleming 2020-08-28T08:52:07.028700Z

I’m using (cljs.closure/add-implicit-options {:cache-analysis false, :npm-deps true}) but I’m still getting that error.

cfleming 2020-08-28T08:52:36.029100Z

But it’s finding and invoking the analyzer fine.

cfleming 2020-08-28T08:55:07.029400Z

Yeah, shadow pulls in cljs, with the analyzer

cfleming 2020-08-28T21:25:09.031200Z

I neglected to provide a final update last night, after digging around with thheller a lot last night, with his help I managed to figure out the problem and find code I can use to fix it in cljdoc.

1
dominicm 2020-08-28T22:26:01.032300Z

That would be the code used to fake foreign libs when they're not present. I still don't understand why they're not present for you. Maybe the api you're using skips that part.