|
219 | 219 | (binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
|
220 | 220 | (closure/watch source opts compiler-env stop))))
|
221 | 221 |
|
222 |
| -(defn add-package-jsons |
223 |
| - "EXPERIMENTAL: see node-module-deps" |
224 |
| - [deps] |
225 |
| - (let [checked (atom #{})] |
226 |
| - (reduce |
227 |
| - (fn [ret {:keys [file] :as dep}] |
228 |
| - (let [f (.getParentFile (io/file file)) |
229 |
| - path (.getAbsolutePath f)] |
230 |
| - (if-not (contains? @checked path) |
231 |
| - (let [f' (io/file f "package.json")] |
232 |
| - (swap! checked conj path) |
233 |
| - (if (.exists f') |
234 |
| - (conj ret dep |
235 |
| - {:file (.getAbsolutePath f') |
236 |
| - :module-type :commonjs}) |
237 |
| - (conj ret dep))) |
238 |
| - (conj ret dep)))) |
239 |
| - [] deps))) |
240 |
| - |
241 | 222 | (defn- alive? [proc]
|
242 | 223 | (try (.exitValue proc) false (catch IllegalThreadStateException _ true)))
|
243 | 224 |
|
|
259 | 240 | (defn node-module-deps
|
260 | 241 | "EXPERIMENTAL: return the foreign libs entries as computed by running
|
261 | 242 | the module-deps package on the supplied JavaScript entry point. Assumes
|
262 |
| - that the module-deps & JSONStream NPM packages are either locally or |
263 |
| - globally installed." |
| 243 | + that the module-deps NPM package is either locally or globally installed." |
264 | 244 | [{:keys [file]}]
|
265 | 245 | (let [code (string/replace
|
266 | 246 | (slurp (io/resource "cljs/module_deps.js"))
|
|
285 | 265 | (into []
|
286 | 266 | (map (fn [{:strs [file]}] file
|
287 | 267 | {:file file :module-type :commonjs}))
|
288 |
| - (butlast (json/read-str (str iw)))) |
| 268 | + (next (json/read-str (str iw)))) |
289 | 269 | (do
|
290 | 270 | (when-not (.isAlive proc)
|
291 | 271 | (println (str ew)))
|
|
295 | 275 | (node-module-deps
|
296 | 276 | {:file (.getAbsolutePath (io/file "src/test/node/test.js"))})
|
297 | 277 |
|
298 |
| - (add-package-jsons |
299 |
| - (node-module-deps |
300 |
| - {:file (.getAbsolutePath (io/file "src/test/node/test.js"))})) |
| 278 | + (node-module-deps |
| 279 | + {:file (.getAbsolutePath (io/file "src/test/node/test.js"))}) |
301 | 280 | )
|
302 | 281 |
|
303 | 282 | (defn node-inputs
|
304 | 283 | "EXPERIMENTAL: return the foreign libs entries as computed by running
|
305 | 284 | the module-deps package on the supplied JavaScript entry points. Assumes
|
306 |
| - that the module-deps & JSONStream NPM packages are either locally or |
307 |
| - globally installed." |
| 285 | + that the module-deps NPM packages is either locally or globally installed." |
308 | 286 | [entries]
|
309 |
| - (add-package-jsons |
310 |
| - (vec (distinct (mapcat node-module-deps entries))))) |
| 287 | + (into [] (distinct (mapcat node-module-deps entries)))) |
311 | 288 |
|
312 | 289 | (comment
|
313 | 290 | (node-inputs
|
|
0 commit comments