added a comment - The reason for these warnings is that under some circumstances, some of the files that don't require compilation (as determined by cljs.compiler/requires-compilation?
), don't get properly analyzed.
Normally when analyzing a file, the analyzer will also analyze all of the namespaces that the current file/namespace depends on (using cljs.analyzer/analyze-deps
). The analyzer tries to avoid analyzing the same namespace twice by checking whether the namespace is already present in cljs.analyzer/namespaces
, see: https://github.com/clojure/clojurescript/blob/f80956d90f455810be140cfec1632f55254385a5/src/clj/cljs/analyzer.clj#L615
When trying to compile a file that doesn't require compilation, cljs.compiler/compile-file
delegates to cljs.compiler/parse-ns
, which uses cljs.analyzer/analyze
to parse the ns
form. Once it reaches the ns
form, it stops further analysis of the file. Analyzing the ns
form has the side effect of populating cljs.analyzer/namespaces
with the basic namespace info (https://github.com/clojure/clojurescript/blob/f80956d90f455810be140cfec1632f55254385a5/src/clj/cljs/analyzer.clj#L710-L721
), preventing the analyzer from subsequently fully analyzing the file in case another file that gets compiled depends on it.
In the example above, the warning will get printed when compiling foo.cljs and fubar.cljs for the second time, after fubar.cljs has changed since first compilation, but foo.cljs hasn't. It will only happen if compile-file
is called on foo.cljs before fubar.cljs. Since foo.cljs doesn't require compilation, only its ns
form will get analyzed, and basic namespace info put into cljs.analyzer/namespaces
. When compile-file
gets called on fubar.cljs later, the analyzer will see that fubar.cljs depends on foo.cljs, but will not go on to analyze it since 'foo.cljs
will already be present in cljs.analyzer/namespaces
I'm attaching a patch that tries to reverse the change that parse-ns
makes to cljs.analyzer/namespaces
. It is the simplest patch I could come up with, although it would probably be more appropriate to not use cljs.analyzer/analyze
to parse the namespace form in parse-ns
at all, but instead create a separate function (cljs.analyzer/analyze-file-ns
( ? )) whose only purpose would be to gather file's namespace info, without changing the analyzer's state.