Skip to content

Commit 0da3496

Browse files
committed
support mutiple evaluations at REPL by attaching timestamp to
inline source maps
1 parent dbf10e5 commit 0da3496

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/main/cljs/cljs/js.cljs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,31 @@
120120
:gen-col 0
121121
:gen-line 0}))
122122

123-
(defn append-source-map [state name source sb sm-data opts]
123+
(defn prefix [s pre]
124+
(str pre s))
125+
126+
(defn append-source-map
127+
[state name source sb sm-data {:keys [output-dir asset-path] :as opts}]
124128
(let [t (.valueOf (js/Date.))
125129
smn (if name
126-
(munge name)
130+
(string/replace (munge (str name)) "." "/")
127131
(str "cljs-" t))
128-
src (str smn ".cljs")
129-
file (str smn ".js")
132+
ts (.valueOf (js/Date.))
133+
out (or output-dir asset-path)
134+
src (cond-> (str smn ".cljs?rel=" ts)
135+
out (prefix (str out "/")))
136+
file (cond-> (str smn ".js?rel=" ts)
137+
out (prefix (str out "/")))
130138
json (sm/encode {src (:source-map sm-data)}
131139
{:lines (+ (:gen-line sm-data) 3)
132-
:file file :sources-content [source]})]
140+
:file file :sources-content [source]})]
133141
(when (:verbose opts) (debug-prn json))
134142
(swap! state assoc-in
135143
[:source-maps name] (sm/invert-reverse-map (:source-map sm-data)))
136144
(.append sb
137145
(str "\n//# sourceURL=" file
138146
"\n//# sourceMappingURL=data:application/json;base64,"
139-
(base64/encodeString json true)))))
147+
(base64/encodeString json)))))
140148

141149
;; -----------------------------------------------------------------------------
142150
;; Analyze

0 commit comments

Comments
 (0)