Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get nil error when integrate with other framework like Luminus #13

Closed
pkvov opened this issue Jan 28, 2015 · 5 comments
Closed

get nil error when integrate with other framework like Luminus #13

pkvov opened this issue Jan 28, 2015 · 5 comments

Comments

@pkvov
Copy link

pkvov commented Jan 28, 2015

(defn discover-macros [state]
595 ;; build {macro-ns #{used-by-source-by-name ...}}
596 (let [macro-info (->> (:sources state)
597 (vals)
598 (filter #(seq (:macros %)))
599 (reduce (ƒ [macro-info {:keys [macros name]}]
600 (reduce (ƒ [macro-info macro-ns]
601 (update-in macro-info [macro-ns] set-conj name))
602 macro-info
603 macros))
604 {})
605 (map (ƒ [[macro-ns used-by]]
606 (let [name (str (ns->path macro-ns) ".clj")
607 url (io/resource name)]
608 {:ns macro-ns
609 :used-by used-by
610 :name name
611 :url url})))
612 (map (ƒ [{:keys [url] :as info}]
613 (when url
614 (if (not= "file" (.getProtocol url))
615 info
616 (let [file (io/file (.getPath url))]
617 (assoc info
618 :file file
619 :last-modified (.lastModified file)))))
620 ))
621 (map (juxt :name identity))
622 (into {}))]
623 (assoc state :macros macro-info)
624 ))

add line no 613 can fixed the problem

@pkvov
Copy link
Author

pkvov commented Jan 28, 2015

it seams that shadow-build will seek all the cljs dependencies in current project, and get some unexcept error. to avoid of this, i have to setup other project to generate the js script and out to my Luminus project resource folder.

@thheller
Copy link
Owner

It seems like a macro namespace is not found. Which either means the macro file is not on the classpath or does not exist at all. Do you have macros (.clj files) that are not on the classpath? shadow-build does not manage the classpath so you might have to add the source-path in leiningen.

@thheller
Copy link
Owner

I just pushed a new update that throws a proper error when a macro is not found, should be easier to track down the missing macro then.

git clone https://github.com/thheller/shadow-build.git
cd shadow-build
lein install

[thheller/shadow-build "1.0.0-alpha6"] is the version.

@pkvov
Copy link
Author

pkvov commented Jan 29, 2015

i used Cider find that which namespace cause the url to nil
in shadow/cljs/build.clj function discover-macros line 657. add (println "name:" name "url:" url), and i got this:

-> Find cljs resources in jars
<- Find cljs resources in jars (1209ms)
-> Find cljs resources in path: "src-cljs"
<- Find cljs resources in path: "src-cljs" (30ms)
name: poppea.clj url: #<URL jar:file:/Users/kepeng/.m2/repository/net/colourcoding/poppea/0.2.0/poppea-0.2.0.jar!/poppea.clj>
name: cljs/core/async/macros.clj url: #<URL jar:file:/Users/kepeng/.m2/repository/org/clojure/core.async/0.1.303.0-886421-alpha/core.async-0.1.303.0-886421-alpha.jar!/cljs/core/async/macros.clj>
name: cljs/core/async/impl/ioc_macros.clj url: #<URL jar:file:/Users/kepeng/.m2/repository/org/clojure/core.async/0.1.303.0-886421-alpha/core.async-0.1.303.0-886421-alpha.jar!/cljs/core/async/impl/ioc_macro
s.clj>
name: reagent/interop.clj url: #<URL jar:file:/Users/kepeng/.m2/repository/reagent/reagent/0.5.0-alpha/reagent-0.5.0-alpha.jar!/reagent/interop.clj>
name: ajax/macros.clj url: #<URL jar:file:/Users/kepeng/.m2/repository/cljs-ajax/cljs-ajax/0.3.3/cljs-ajax-0.3.3.jar!/ajax/macros.clj>
name: taoensso/tower.clj url: #<URL jar:file:/Users/kepeng/.m2/repository/com/taoensso/tower/3.0.2/tower-3.0.2.jar!/taoensso/tower.clj>
name: quiescent/dom.clj url: nil
NullPointerException clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:301)

name: quiescent/dom.clj url: nil case the error, and i finally found that it was [prone "0.8.0"](A Better exception reporting middleware for Ring) introduce the dependency of [quiescent "0.1.4"]
and after remove the [prone "0.8.0"], both cljs-dev and cljs-prod can compile and works OK.

thanks a lot.

now i take careful of the dependency, cause the problem. now i put every cljs dependency under the :dev tag

@thheller
Copy link
Owner

I just looked at prone. It ships with a whole lot of external javascript, the cljs.core.async source for example. But it only ships with the .cljs sources (not the macros) which causes a bunch of errors.

Opened magnars/prone#21 as I think that should be cleaned up, I imagine this causes a lot of "hidden" issues for other people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants