|
220 | 220 | (when-let [smf (util/file-or-resource (str f ".map"))]
|
221 | 221 | (let [ns (if (= f "cljs/core.aot.js")
|
222 | 222 | 'cljs.core
|
223 |
| - (:ns (ana/parse-ns (js-src->cljs-src f))))] |
224 |
| - (as-> @env/*compiler* compiler-env |
225 |
| - (let [t (util/last-modified smf)] |
226 |
| - (if (or (and (= ns 'cljs.core) |
227 |
| - (nil? (get-in compiler-env [::source-maps ns]))) |
228 |
| - (and (not= ns 'cljs.core) |
229 |
| - (> t (get-in compiler-env [::source-maps ns :last-modified] 0)))) |
230 |
| - (swap! env/*compiler* assoc-in [::source-maps ns] |
231 |
| - {:last-modified t |
232 |
| - :source-map (sm/decode (json/read-str (slurp smf) :key-fn keyword))}) |
233 |
| - compiler-env)) |
234 |
| - (get-in compiler-env [::source-maps ns :source-map]))))) |
| 223 | + (some-> (js-src->cljs-src f) ana/parse-ns :ns))] |
| 224 | + (when ns |
| 225 | + (as-> @env/*compiler* compiler-env |
| 226 | + (let [t (util/last-modified smf)] |
| 227 | + (if (or (and (= ns 'cljs.core) |
| 228 | + (nil? (get-in compiler-env [::source-maps ns]))) |
| 229 | + (and (not= ns 'cljs.core) |
| 230 | + (> t (get-in compiler-env [::source-maps ns :last-modified] 0)))) |
| 231 | + (swap! env/*compiler* assoc-in [::source-maps ns] |
| 232 | + {:last-modified t |
| 233 | + :source-map (sm/decode (json/read-str (slurp smf) :key-fn keyword))}) |
| 234 | + compiler-env)) |
| 235 | + (get-in compiler-env [::source-maps ns :source-map])))))) |
235 | 236 |
|
236 | 237 | (defn ns-info
|
237 | 238 | "Given a path to a js source file return the ns info for the corresponding
|
238 | 239 | ClojureScript file if it exists."
|
239 | 240 | [f]
|
240 | 241 | (let [f' (js-src->cljs-src f)]
|
241 |
| - (when (.exists f') |
| 242 | + (when (and f' (.exists f')) |
242 | 243 | (ana/parse-ns f'))))
|
243 | 244 |
|
244 | 245 | (defn- mapped-line-column-call
|
|
334 | 335 | print the ClojureScript stacktrace. See mapped-stacktrace."
|
335 | 336 | ([stacktrace] (print-mapped-stacktrace stacktrace *repl-opts*))
|
336 | 337 | ([stacktrace opts]
|
337 |
| - (doseq [{:keys [function file line column]} |
338 |
| - (mapped-stacktrace stacktrace opts)] |
339 |
| - (err-out |
340 |
| - (println "\t" |
341 |
| - (str (when function (str function " ")) |
342 |
| - "(" file (when line (str ":" line)) (when column (str ":" column)) ")")))))) |
| 338 | + (doseq [{:keys [function file line column]} |
| 339 | + (mapped-stacktrace stacktrace opts)] |
| 340 | + (err-out |
| 341 | + (println "\t" |
| 342 | + (str (when function (str function " ")) |
| 343 | + "(" file (when line (str ":" line)) (when column (str ":" column)) ")")))))) |
343 | 344 |
|
344 | 345 | (comment
|
345 | 346 | (cljsc/build "samples/hello/src"
|
|
0 commit comments