cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
2020-04-03T12:41:38.152600Z

Is it a known issue where async cljs tests are running twice after hot reload?

2020-04-03T12:42:37.153300Z

Feels like test env is not being cleared, but looking at the code cleaning the env is always called in the end.

dnolen 2020-04-03T12:47:20.153800Z

@roman01la don't think anyone has reported that bug before

dnolen 2020-04-03T12:47:34.154300Z

but goes w/o saying this needs reproducer w/ just ClojureScript

dnolen 2020-04-03T12:47:40.154500Z

i.e. standard REPL only

dnolen 2020-04-03T12:47:47.154800Z

(require 'foo :reload)

2020-04-03T12:48:50.155300Z

ok, I'll try that

dnolen 2020-04-03T13:16:30.155900Z

I will note that I use the standard Node.js REPL and reload test namespaces quite a bit and I've never seen this problem

2020-04-03T13:17:25.156300Z

Just tried it, couldn't repro as well

2020-04-03T13:17:55.156700Z

time to dig into tooling... 😫

ak-coram 2020-04-03T14:27:32.157500Z

I have the following issue with trying to use cljs.analyzer.api https://clojurians.slack.com/archives/C03S1L9DN/p1585922766236400

ak-coram 2020-04-03T14:30:34.159300Z

by external dependencies I mean the CLJS/JS sources that are not directly part of my project, but are added to my classpath via tools.deps

ak-coram 2020-04-03T14:31:51.160700Z

I can build my project just fine via cljs.build.api and I'm not sure how cljs.analyzer.api is different in handling these dependencies

dnolen 2020-04-03T14:32:10.161Z

you need to make sure you're using the deps alias

dnolen 2020-04-03T14:32:55.161800Z

also an example of the api calls you're making would be helpful

ak-coram 2020-04-03T14:36:27.163Z

sure, so for building this works fine:

(cljs.build.api/build
 {:output-to "resources/public/js/app.js"
  :output-dir "target/cljs"
  :externs ["lib/externs.js"]
  :optimizations :advanced
  :main "example.core"
  :source-map false
  :pretty-print false
  :pseudo-names false
  :elide-asserts true
  :fn-invoke-direct true
  :parallel-build true})

ak-coram 2020-04-03T14:39:51.163500Z

but when I try to run analyze with the same options:

(cljs.analyzer.api/analyze-file (<http://clojure.java.io/file|clojure.java.io/file> "src/cljs/example/core.cljs") {...same options...})

ak-coram 2020-04-03T14:40:29.163800Z

I get No such namespace: react, could not locate react.cljs, react.cljc, or JavaScript source providing "react" in file file:/usr/home/ak/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/reagent/core.cljs

ak-coram 2020-04-03T14:43:38.164400Z

let me know if I can provide any additional info

dnolen 2020-04-03T14:50:34.165500Z

@ak407 yeah you can't call it like that - you need to make a compiler state first and pass it as the first argument

dnolen 2020-04-03T14:53:13.165900Z

@ak407 and there's actually no good way to do it via a public api in the current release

ak-coram 2020-04-03T15:02:54.166800Z

@dnolen: thanks, good to know. any non-public api I can use? 🙂

dnolen 2020-04-03T15:04:15.167400Z

(cljs.env/default-compiler-env compiler-options)

dnolen 2020-04-03T15:04:35.167800Z

then try passing that as first arg to analyze-file

dnolen 2020-04-03T15:06:56.168900Z

@ak407 if you're doing tooling or heavy-duty analysis also not much wrong w/ just using the analyzer directly - there's the risk that your tool might break of course but you just have to live w/ that

dnolen 2020-04-03T15:08:23.169400Z

we don't change the details of the analyzer that often

ak-coram 2020-04-03T16:12:19.169800Z

@dnolen: thanks again, I'll give it a shot

dnolen 2020-04-03T16:13:17.170400Z

@ak407 in the next release this will be cleaned up a bit if you discover analyze-file is good enough for what you want to accomplish

dnolen 2020-04-03T16:13:52.171200Z

(ana.api/analyze-file (ana.api/empty-state options) ...)