ns-tracker
ns-tracker copied to clipboard
Improve the order in which `ns-tracker` returns the namespaces
Hi! I'm using this library because pedestal uses it to reload the files.
The problem is that ns-tracker
doesn't return the namespaces in the order in which each file depends on the other (by depending I mean the :require
at the top ns declaration). For example, if I have 3 files:
(ns first)
(def f 1)
(ns second
(:require [first]))
(def s (+ 2 first/f))
(ns third
(:require [second]))
(def t second/s)
Now, using ns-tracker:
(def t (ns-tracker ["src"]))
;; after editing and saving `first.clj` I do:
(t)
;; => (first third second)
Let's say that I changed first/f
to 30, the problem is that if I reload them in that order, then third/d
will have the older value:
(require 'first :reload)
(require 'third :reload)
(require 'second :reload)
first/f ;; => 30
second/s ;; => 32
third/t ;; => 3
Now, I wanted to ask, is this expected or it is a bug?
Also ran into this issue, fixed it in this fork https://github.com/liftoffio/ns-tracker/commit/d016c781268d8249e9d4ecf52d3b2eacad81c853
This issue slipped through the cracks of my inbox the first time around. This does appear to be a bug, and I'd accept a PR to fix it.