|
71 | 71 |
|
72 | 72 | :lang - the language, :clj or :js
|
73 | 73 | :source - the source of the library (a string)
|
| 74 | + :file - optional, the file path, it will be added to AST's :file keyword |
| 75 | + (but not in :meta) |
74 | 76 | :cache - optional, if a :clj namespace has been precompiled to :js, can
|
75 | 77 | give an analysis cache for faster loads.
|
76 | 78 | :source-map - optional, if a :clj namespace has been precompiled to :js, can
|
|
246 | 248 | (assert (or (map? resource) (nil? resource))
|
247 | 249 | "*load-fn* may only return a map or nil")
|
248 | 250 | (if resource
|
249 |
| - (let [{:keys [lang source cache source-map]} resource] |
| 251 | + (let [{:keys [lang source cache source-map file]} resource] |
250 | 252 | (condp = lang
|
251 |
| - :clj (eval-str* bound-vars source name opts |
| 253 | + :clj (eval-str* bound-vars source name (assoc opts :cljs-file file) |
252 | 254 | (fn [res]
|
253 | 255 | (if (:error res)
|
254 | 256 | (cb res)
|
|
379 | 381 | (assert (or (map? resource) (nil? resource))
|
380 | 382 | "*load-fn* may only return a map or nil")
|
381 | 383 | (if resource
|
382 |
| - (let [{:keys [name lang source]} resource] |
| 384 | + (let [{:keys [name lang source file]} resource] |
383 | 385 | (condp = lang
|
384 |
| - :clj (analyze-str* bound-vars source name opts |
| 386 | + :clj (analyze-str* bound-vars source name (assoc opts :cljs-file file) |
385 | 387 | (fn [res]
|
386 | 388 | (if-not (:error res)
|
387 | 389 | (analyze-deps bound-vars ana-env lib (next deps) opts cb)
|
|
517 | 519 | r/*alias-map* (current-alias-map)
|
518 | 520 | r/*data-readers* (:*data-readers* bound-vars)
|
519 | 521 | r/resolve-symbol resolve-symbol
|
520 |
| - comp/*source-map-data* (:*sm-data* bound-vars)] |
| 522 | + comp/*source-map-data* (:*sm-data* bound-vars) |
| 523 | + ana/*cljs-file* (:cljs-file opts)] |
521 | 524 | (let [res (try
|
522 | 525 | {:value (r/read {:eof eof :read-cond :allow :features #{:cljs}} rdr)}
|
523 | 526 | (catch :default cause
|
|
780 | 783 | r/*alias-map* (current-alias-map)
|
781 | 784 | r/*data-readers* (:*data-readers* bound-vars)
|
782 | 785 | r/resolve-symbol resolve-symbol
|
783 |
| - comp/*source-map-data* (:*sm-data* bound-vars)] |
| 786 | + comp/*source-map-data* (:*sm-data* bound-vars) |
| 787 | + ana/*cljs-file* (:cljs-file opts)] |
784 | 788 | (let [res (try
|
785 | 789 | {:value (r/read {:eof eof :read-cond :allow :features #{:cljs}} rdr)}
|
786 | 790 | (catch :default cause
|
|
0 commit comments