|
62 | 62 | respected). Upon resolution the callback should be invoked with a map
|
63 | 63 | containing the following keys:
|
64 | 64 |
|
65 |
| - :lang - the language, :clj or :js |
66 |
| - :source - the source of the library (a string) |
67 |
| - :cache - optional, if a :clj namespace has been precompiled to :js, can give |
68 |
| - an analysis cache for faster loads. |
| 65 | + :lang - the language, :clj or :js |
| 66 | + :source - the source of the library (a string) |
| 67 | + :cache - optional, if a :clj namespace has been precompiled to :js, can |
| 68 | + give an analysis cache for faster loads. |
| 69 | + :source-map - optional, if a :clj namespace has been precompiled to :js, can |
| 70 | + give a V3 source map JSON |
69 | 71 |
|
70 | 72 | If the resource could not be resolved, the callback should be invoked with
|
71 | 73 | nil."
|
|
113 | 115 | (defn load-analysis-cache! [state ns cache]
|
114 | 116 | (swap! state assoc-in [::ana/namespaces ns] cache))
|
115 | 117 |
|
| 118 | +(defn load-source-map! [state ns sm-json] |
| 119 | + (let [sm (sm/decode (.parse js/JSON sm-json))] |
| 120 | + (swap! state assoc-in [:source-maps ns] sm))) |
| 121 | + |
116 | 122 | (defn sm-data []
|
117 | 123 | (atom
|
118 | 124 | {:source-map (sorted-map)
|
|
182 | 188 | (assert (or (map? resource) (nil? resource))
|
183 | 189 | "*load-fn* may only return a map or nil")
|
184 | 190 | (if resource
|
185 |
| - (let [{:keys [lang source cache]} resource] |
| 191 | + (let [{:keys [lang source cache source-map]} resource] |
186 | 192 | (condp = lang
|
187 | 193 | :clj (eval-str* bound-vars source name opts
|
188 | 194 | (fn [res]
|
|
194 | 200 | (when cache
|
195 | 201 | (load-analysis-cache!
|
196 | 202 | (:*compiler* bound-vars) name cache))
|
| 203 | + (when source-map |
| 204 | + (load-source-map! |
| 205 | + (:*compiler* bound-vars) name source-map)) |
197 | 206 | (catch :default cause
|
198 | 207 | (wrap-error
|
199 | 208 | (ana/error env
|
|
0 commit comments