This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-10
Channels
- # announcements (1)
- # beginners (2)
- # calva (41)
- # cider (3)
- # cljdoc (2)
- # cljs-dev (23)
- # clojure (94)
- # clojure-dev (23)
- # clojure-russia (5)
- # clojure-spec (9)
- # clojure-uk (85)
- # clojurescript (94)
- # code-reviews (1)
- # cursive (5)
- # datomic (1)
- # emacs (8)
- # figwheel (1)
- # figwheel-main (10)
- # fulcro (27)
- # graphql (11)
- # hyperfiddle (1)
- # jobs-discuss (10)
- # kaocha (3)
- # luminus (7)
- # lumo (1)
- # off-topic (85)
- # onyx (1)
- # pedestal (1)
- # re-frame (3)
- # shadow-cljs (21)
- # tools-deps (1)
- # yada (6)
@anmonteiro awesome, thanks a bunch!
I found add-implicit-options
which seems to rename some of the libraries related keys needed for this (in addition to get-upstream-deps
which Antonio suggested)
(ana/analyze-file state file (cljs.closure/add-implicit-options {}))
react
can still not be found despite the returned options listing it. I found the lines below which seem to indicate that there's more processing needed but it also seems that this requires a full compiler environment (compared to just analysis)
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L2944-L2946
Am I missing something or is this the way to go?Still somewhat stuck here... I think the js-dependency-index
thing is probably not needed since only the :options
part of the overall compiler opts
map is passed to analyze-file
...
But not sure what else is needed... For context in case it got lost in scrollback:
I'm trying to use analyze-file
on some files that require react
and somehow I can't figure out how to correctly pass the information about where the react
lib can be found to analyze-file
.
Wrote up problem statement and some notes here (code with minimal deps as well): https://gist.github.com/martinklepsch/9f885feb061ec3f03f365e22d0d9bf5b
If anyone could take a look and perhaps point me in the right direction that would be super lovely. (People familiar with :js-dependency-index
might be particularly able to help)
I think I found the issue! 😅
state (ana/empty-state)
this already accesses the compiler-env so should be done inside the binding
yeah passing state
to analyze-file
shadowed the compiler env
that was the issue and the reason my contains?
returned the correct value
(defn- analyze-file [file]
(let [state (cljs.env/default-compiler-env opts)
opts (cljs.closure/add-implicit-options {})] ; also calls `get-upstream-deps`
(binding [cljs.env/*compiler* state
an/*analyze-deps* true] ; (probably default)
(println "REACT FOUND?" (contains? (:js-dependency-index @cljs.env/*compiler*) "react"))
(ana/no-warn
(cljs.closure/validate-opts opts)
(ana/analyze-file state file opts)))
state))
Well the binding isn't ever used due to the with-compiler-env
thing in ana.api/analyze-file
solution is as basic as this:
(defn- analyze-file [file]
(let [opts (cljs.closure/add-implicit-options {})
state (cljs.env/default-compiler-env opts)]
(ana/no-warn
(cljs.closure/validate-opts opts)
(ana/analyze-file state file opts))
state))
Maybe were misunderstanding each other but I think with-compiler-env
ignores any pre-existing *compiler*
binding
AFAICT you just had 2 different state instances and only one had the js-deps populated
yeah that's my understanding too
Wrote up problem statement and some notes here (code with minimal deps as well): https://gist.github.com/martinklepsch/9f885feb061ec3f03f365e22d0d9bf5b
If anyone could take a look and perhaps point me in the right direction that would be super lovely. (People familiar with :js-dependency-index
might be particularly able to help)
I think I found the issue! 😅