Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

relative source map paths

  • Loading branch information...
commit 69f0060617ad54da476396a9632023f56b381871 1 parent 7d3ce70
@swannodette swannodette authored
Showing with 24 additions and 7 deletions.
  1. +5 −2 src/clj/cljs/closure.clj
  2. +19 −5 src/clj/cljs/source_map.clj
View
7 src/clj/cljs/closure.clj
@@ -746,7 +746,9 @@
merged)))
(spit (io/file name)
(sm/encode merged
- {:lines (+ (:lineCount sm-json) 2) :file (:file sm-json)}))))))
+ {:lines (+ (:lineCount sm-json) 2)
+ :file (:file sm-json)
+ :output-dir (:output-dir opts)}))))))
source)
(report-failure result))))
@@ -989,7 +991,8 @@
(when-let [fname (:source-map all-opts)]
(assert (string? fname)
(str ":source-map must name a file when using :whitespace, "
- ":simple, or :advanced optimizations")))
+ ":simple, or :advanced optimizations"))
+ (doall (map #(source-on-disk all-opts %) js-sources)))
(->> js-sources
(apply optimize all-opts)
(add-wrapper all-opts)
View
24 src/clj/cljs/source_map.clj
@@ -152,6 +152,14 @@
[] cols)))
[] lines)))
+(defn relativize-path [path output-dir]
+ (cond
+ (re-find #"\.jar!/" path)
+ (str output-dir (second (string/split path #"\.jar!")))
+
+ :else
+ (string/replace path (str (System/getProperty "user.dir") "/") "")))
+
(defn encode
"Take an internal source map representation represented as nested
sorted maps of file, line, column and return a source map v3 JSON
@@ -193,13 +201,19 @@
(json/pprint
{"version" 3
"file" (:file opts)
- "sources" (into [] (keys m))
+ "sources" (into []
+ (let [paths (keys m)
+ f (if-let [output-dir (:output-dir opts)]
+ #(relativize-path % output-dir)
+ #(last (string/split % #"/")))]
+ (map f paths)))
"lineCount" (:lines opts)
"mappings" (->> (lines->segs @lines)
- (map #(string/join "," %))
- (string/join ";"))
- "names" (into [] (map (set/map-invert @names->idx)
- (range (count @names->idx))))}
+ (map #(string/join "," %))
+ (string/join ";"))
+ "names" (into []
+ (map (set/map-invert @names->idx)
+ (range (count @names->idx))))}
:escape-slash false))))
;; -----------------------------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.