I was wondering if the tool could be also used on Clojurescript projects.
It seems that tools.namespace suuports cljs. I did a quick experiment and was able to make it parse cljs files by replacing (namespace.find/find-ns-decls-in-dir file) with (namespace.find/find-ns-decls-in-dir file namespace.find/cljs) in parser.clj. So it should be possible to expose it up with some kind of option.
Following that I encountered circular dependency issue when namespaces require macros which halts the analysis.
For example foo.cljs:
(ns foo
(:require-macros [foo]))
or foo.cljc:
(ns foo
#?(:cljs (:require-macros [foo]))
There does not seem to be a way to override how tools.namespace treats circular dependencies, but I found a workaround by wrapping a line in dependency.clj in try/catch and ignoring circular dependencies. I don't see much value for the analysis tool to check circular dependencies in Clojure given it is already enforces that. But perhaps there could be an option for that.
(try
(namespace.dependency/depend graph (:name namespace) dep)
(catch Exception e
(if (= (:reason (ex-data e))
::namespace.dependency/circular-dependency)
graph
(throw e)))))
With that I was able to make the analysis work. What probably needs some thinking is how to expose the option. Whether to specify it globally or just per layer(s). I am thinking for full-stack projects that consist of server clj code, client cljs and shared cljc, it would be useful to check all dialects at the same time.
I was wondering if the tool could be also used on Clojurescript projects.
It seems that tools.namespace suuports cljs. I did a quick experiment and was able to make it parse cljs files by replacing
(namespace.find/find-ns-decls-in-dir file)with(namespace.find/find-ns-decls-in-dir file namespace.find/cljs)in parser.clj. So it should be possible to expose it up with some kind of option.Following that I encountered circular dependency issue when namespaces require macros which halts the analysis.
For example foo.cljs:
or foo.cljc:
There does not seem to be a way to override how tools.namespace treats circular dependencies, but I found a workaround by wrapping a line in dependency.clj in try/catch and ignoring circular dependencies. I don't see much value for the analysis tool to check circular dependencies in Clojure given it is already enforces that. But perhaps there could be an option for that.
With that I was able to make the analysis work. What probably needs some thinking is how to expose the option. Whether to specify it globally or just per layer(s). I am thinking for full-stack projects that consist of server clj code, client cljs and shared cljc, it would be useful to check all dialects at the same time.