(merge-source-maps cljs-map js-map)
Merge an internal source map representation of a single
ClojureScript file mapping original to generated with a
second source map mapping original JS to generated JS.
The is to support source maps that work through multiple
compilation steps like Google Closure optimization passes.
Source
(defn
merge-source-maps
"Merge an internal source map representation of a single\n ClojureScript file mapping original to generated with a\n second source map mapping original JS to generated JS.\n The is to support source maps that work through multiple\n compilation steps like Google Closure optimization passes."
[cljs-map js-map]
(loop
[line-map-seq (seq cljs-map) new-lines (sorted-map)]
(if
line-map-seq
(let
[[line col-map]
(first line-map-seq)
new-cols
(loop
[col-map-seq (seq col-map) new-cols (sorted-map)]
(if
col-map-seq
(let
[[col infos] (first col-map-seq)]
(recur
(next col-map-seq)
(assoc
new-cols
col
(reduce
(fn
[v {:keys [gline gcol]}]
(into v (get-in js-map [gline gcol])))
[]
infos))))
new-cols))]
(recur (next line-map-seq) (assoc new-lines line new-cols)))
new-lines)))