Skip to content

Commit

Permalink
adding meta data for ns; we can now prevent loading an force loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Hauman committed Dec 16, 2014
1 parent 0dbac26 commit 212a881
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
13 changes: 9 additions & 4 deletions sidecar/src/figwheel_sidecar/core.clj
Expand Up @@ -139,13 +139,14 @@
.ie a file that starts with (ns example.path-finder) -> example.path_finder"
[file-path]
(try

(when (.exists (as-file file-path))
(with-open [rdr (io/reader file-path)]
(-> (java.io.PushbackReader. rdr)
read
second
name
underscore)))
#_name
#_underscore)))
(catch java.lang.RuntimeException e
nil)))

Expand Down Expand Up @@ -228,8 +229,12 @@
(defn make-sendable-file
"Formats a namespace into a map that is ready to be sent to the client."
[st nm]
{ :file (ns-to-server-relative-path st nm)
:namespace (cljs.compiler/munge nm) })
(let [n (-> nm name underscore)]
{ :file (ns-to-server-relative-path st n)
:namespace (cljs.compiler/munge n)
:meta-data (meta nm)}
))


;; I would love to just check the compiled javascript files to see if
;; they changed and then just send them to the browser. There is a
Expand Down
18 changes: 14 additions & 4 deletions support/src/figwheel/client/file_reloading.cljs
Expand Up @@ -18,10 +18,20 @@
(string/split #"/")
first))

(defn js-reload [{:keys [request-url namespace dependency-file] :as msg} callback]
(if (or dependency-file
;; IMPORTANT make sure this file is currently provided
(.isProvided_ js/goog (name namespace)))
(defonce ns-meta-data (atom {}))

(defn get-meta-data-for-ns [ns]
(get ns-meta-data ns))

(defn js-reload [{:keys [request-url namespace dependency-file meta-data] :as msg} callback]
(swap! ns-meta-data assoc namespace meta-data)
(print (pr-str @ns-meta-data))
(if (and
(or dependency-file
(and meta-data (:figwheel-load meta-data))
;; IMPORTANT make sure this file is currently provided
(.isProvided_ js/goog (name namespace)))
(not (:figwheel-no-load (or meta-data {}))))
(.addCallback (loader/load (add-cache-buster request-url) #js { :cleanupWhenDone true })
#(apply callback [(assoc msg :loaded-file true)]))
(apply callback [msg])))
Expand Down

0 comments on commit 212a881

Please sign in to comment.