Skip to content

Commit ea40068

Browse files
mfikesdnolen
authored andcommitted
CLJS-1564: Self-host: cached macro *loaded* update
When requiring namespaces, the namespace name symbol is conjed into the *loaded* set, with the ana/macro-ns-name being conjed in the case of a macros namespace. (So for example, 'foo.core for a regular namespace and 'foo.core$macros for a macros namespace.) But, if the namespace being loaded is a macros namespace for which the client returns cached JavaScript, then the code instead conjes the base namespace name. This is actually the result of a simple oversight with the changes made for CLJS-1504: One place where *loaded* is manipulated, name is used instead of aname.
1 parent 2023353 commit ea40068

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/main/cljs/cljs/js.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
(if (:error res)
268268
(cb res)
269269
(do
270-
(swap! *loaded* conj name)
270+
(swap! *loaded* conj aname)
271271
(cb {:value true}))))))))))
272272
(cb (wrap-error
273273
(ana/error env

src/test/self/self_host/test.cljs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,60 @@
5050
;; NOTE: can't set passes because callbacks happen _inside_ binding
5151
;; do so will effect other tests
5252

53+
(deftest test-require-updates-*loading*
54+
(async done
55+
(let [l (latch 4 done)]
56+
(cljs/require
57+
{}
58+
'load1.core
59+
:reload-all
60+
{:load (fn [_ cb] (cb {:lang :clj
61+
:source "(ns load1.core)"}))
62+
:eval (constantly nil)}
63+
(fn [{:keys [error value]}]
64+
(is (nil? error))
65+
(is value)
66+
(is (= #{'load1.core} @cljs/*loaded*))
67+
(inc! l)))
68+
(cljs/require
69+
{}
70+
'load2.core
71+
:reload-all
72+
{:macros-ns true
73+
:load (fn [_ cb] (cb {:lang :clj
74+
:source "(ns load2.core)"}))
75+
:eval (constantly nil)}
76+
(fn [{:keys [error value]}]
77+
(is (nil? error))
78+
(is value)
79+
(is (= #{'load2.core$macros} @cljs/*loaded*))
80+
(inc! l)))
81+
(cljs/require
82+
{}
83+
'load3.core
84+
:reload-all
85+
{:load (fn [_ cb] (cb {:lang :js
86+
:source ""}))
87+
:eval (constantly nil)}
88+
(fn [{:keys [error value]}]
89+
(is (nil? error))
90+
(is value)
91+
(is (= #{'load3.core} @cljs/*loaded*))
92+
(inc! l)))
93+
(cljs/require
94+
{}
95+
'load4.core
96+
:reload-all
97+
{:macros-ns true
98+
:load (fn [_ cb] (cb {:lang :js
99+
:source ""}))
100+
:eval (constantly nil)}
101+
(fn [{:keys [error value]}]
102+
(is (nil? error))
103+
(is value)
104+
(is (= #{'load4.core$macros} @cljs/*loaded*))
105+
(inc! l))))))
106+
53107
(deftest test-analyze-str
54108
(async done
55109
(let [l (latch 3 done)]

0 commit comments

Comments
 (0)