Fork me on GitHub
#cljs-dev
<
2020-04-03
>
Roman Liutikov12:04:38

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

Roman Liutikov12:04:37

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

dnolen12:04:20

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

dnolen12:04:34

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

dnolen12:04:40

i.e. standard REPL only

dnolen12:04:47

(require 'foo :reload)

Roman Liutikov12:04:50

ok, I'll try that

dnolen13:04:30

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

Roman Liutikov13:04:25

Just tried it, couldn't repro as well

Roman Liutikov13:04:55

time to dig into tooling... 😫

ak-coram14:04:32

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

ak-coram14:04:34

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-coram14:04:51

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

dnolen14:04:10

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

dnolen14:04:55

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

ak-coram14:04:27

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-coram14:04:51

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

(cljs.analyzer.api/analyze-file ( "src/cljs/example/core.cljs") {...same options...})

ak-coram14:04:29

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-coram14:04:38

let me know if I can provide any additional info

dnolen14:04:34

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

dnolen14:04:13

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

ak-coram15:04:54

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

dnolen15:04:15

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

dnolen15:04:35

then try passing that as first arg to analyze-file

dnolen15:04:56

@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

dnolen15:04:23

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

ak-coram16:04:19

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

dnolen16:04:17

@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

dnolen16:04:52

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