We're updating the issue view to help you get more done. 

Recompile dependents broken when files are not inside one directory


When a file is changed files dependent on that file are marked for recompile. This doesn't seem to work when the changed file is not in the directory which is passed to build and the directory where dependent namespace is.

Looks like this caused by how build and compile-file work:

  • Build calls -compile -> compile-dir -> compile-root which sorts the files in dependency order and calls -compile for the files in dependency order

    • core ns is compiled

  • Build calls add-depedencies -> add-dependencies -> get-compiled-cljs -> -compile -> compile-file

    • test ns is compiled, core ns is marked as dependent on test ns but as core ns is already compiled this doesn't matter

I believe this effectively breaks :recompile-dependents in cases all cases but one where all the sources are inside one directory. In multiple directory case order of directories passed to cljs.build.api/inputs affects the order on which compile is called so it's possible that some dependent namespaces are compiled before namespaces they depend on are compiled.

Original problem was that added tests were not picked up by run-tests but I have since reproduced this without cljs.test.

The minimal way to reproduce this needs two namespaces, where one depends on another. To display that the dependent namespace is not recompiled, it will print some compile time metadata from the another namespace.


1 2 3 4 5 6 (ns hello.core (:require hello-world.test)) (enable-console-print!) (println (:foo (meta #'hello.test/a)))


1 2 3 (ns hello.test) (def ^{:foo :bar} a "foobar")

To build:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 (require '[cljs.build.api :refer [build]]) (def opts {:main "hello.core" :output-to "out/main.js" :output-dir "out" :optimizations :none :verbose true}) (defn broken [] (build "src" opts)) (defn working [] " Note: ordering of the dirs matters (build (inputs "src2" "src" opts)))

To trigger the problem, the metadata needs to be changed after running the build once. Changing test ns doesn't cause core ns to recompiled and changing the metadata doesn't have any effect to println on core ns.





David Nolen


Juho Teperi






Fix versions

Affects versions