ClojureScript

Recompile dependents broken when files are not inside one directory

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: 1.7.145
  • Fix Version/s: 1.7.228
  • Component/s: None
  • Labels:

Description

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.

src/hello/core.cljs

(ns hello.core
  (:require hello-world.test))

(enable-console-print!)

(println (:foo (meta #'hello.test/a)))

src2/hello/test.cljs

(ns hello.test)

(def ^{:foo :bar} a "foobar")

To build:

(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.

Activity

David Nolen made changes -
Field Original Value New Value
Fix Version/s Next [ 10651 ]
Affects Version/s 1.7.48 [ 10450 ]
David Nolen made changes -
Labels build
Juho Teperi made changes -
Assignee Juho Teperi [ deraen ]
Juho Teperi made changes -
Attachment compile-dependency-order.patch [ 15041 ]
Juho Teperi made changes -
Attachment compile-dependency-order-a.patch [ 15059 ]
Attachment compile-dependency-order-b.patch [ 15060 ]
Juho Teperi made changes -
Attachment cljs-1437-2b.patch [ 15093 ]
Attachment cljs-1437-2a.patch [ 15094 ]
Juho Teperi made changes -
Attachment cljs-1437-3a.patch [ 15095 ]
Attachment cljs-1437-3b.patch [ 15096 ]
Juho Teperi made changes -
Attachment compile-dependency-order-a.patch [ 15059 ]
Juho Teperi made changes -
Attachment compile-dependency-order-b.patch [ 15060 ]
Juho Teperi made changes -
Attachment compile-dependency-order.patch [ 15041 ]
Juho Teperi made changes -
Attachment cljs-1437-2a.patch [ 15094 ]
Juho Teperi made changes -
Attachment cljs-1437-2b.patch [ 15093 ]
Juho Teperi made changes -
Attachment cljs-1437-3b.patch [ 15096 ]
Juho Teperi made changes -
Attachment cljs-1437-3b.patch [ 15106 ]
David Nolen made changes -
Assignee Juho Teperi [ deraen ] David Nolen [ dnolen ]
David Nolen made changes -
Status Open [ 1 ] In Progress [ 3 ]
David Nolen made changes -
Fix Version/s Backlog [ 10653 ]
Fix Version/s Next [ 10651 ]
Affects Version/s Next [ 10651 ]
Affects Version/s 1.7.48 [ 10450 ]
Juho Teperi made changes -
Attachment cljs-1437-4b.patch [ 15230 ]
Juho Teperi made changes -
Attachment cljs-1437-5.patch [ 15231 ]
Juho Teperi made changes -
Attachment cljs-1437-3a.patch [ 15095 ]
Juho Teperi made changes -
Attachment cljs-1437-3b.patch [ 15106 ]
Juho Teperi made changes -
Attachment cljs-1437-4b.patch [ 15230 ]
Juho Teperi made changes -
Attachment cljs-1437-6.patch [ 15242 ]
Juho Teperi made changes -
Attachment cljs-1437-7.patch [ 15246 ]
Juho Teperi made changes -
Attachment cljs-1437-8.patch [ 15249 ]
Juho Teperi made changes -
Attachment cljs-1437-5.patch [ 15231 ]
Juho Teperi made changes -
Attachment cljs-1437-6.patch [ 15242 ]
Juho Teperi made changes -
Attachment cljs-1437-7.patch [ 15246 ]
David Nolen made changes -
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Completed [ 1 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: