Skip to content

Commit c33c626

Browse files
committed
wip
1 parent a7a4fce commit c33c626

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/nbb/core.cljs

+9-6
Original file line numberDiff line numberDiff line change
@@ -138,24 +138,27 @@
138138
(defn register-module [mod internal-name]
139139
(swap! loaded-modules assoc internal-name mod))
140140

141+
(defn debug [& xs]
142+
(binding [*print-fn* *print-err-fn*]
143+
(apply prn xs)))
144+
141145
(defn load-js-module [libname internal-name reload?]
142146
(-> (if-let [resolve (:resolve @ctx)]
143147
(-> (resolve libname)
144148
(.catch
145149
(fn [_]
146150
((.-resolve (:require @ctx)) libname))))
147151
(js/Promise.resolve ((.-resolve (:require @ctx)) libname)))
148-
(.then (fn [path]
149-
;; (prn :path path)
150-
(let [file-url (if (str/starts-with? path "file:")
152+
(.then (fn [path]
153+
(let [file-url (if (str/starts-with? (str path) "file:")
151154
path
152-
(when (fs/existsSync path)
153-
(url/pathToFileURL path)))
155+
(when (fs/existsSync path)
156+
(str (url/pathToFileURL path))))
154157
path (if (and reload?
155158
;; not "node:fs" etc
156159
file-url)
157160
(str file-url "?uuid=" (random-uuid))
158-
path)]
161+
(or file-url path))]
159162
(esm/dynamic-import path))))
160163
(.then (fn [mod]
161164
(register-module mod internal-name)

0 commit comments

Comments
 (0)