/
build.clj
85 lines (73 loc) · 4.84 KB
/
build.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
(ns script.bootstrap.build
(:require [clojure.java.io :as io]
[cljs.build.api :as api]
[cljs.analyzer]
[cognitect.transit :as transit])
(:import [java.io ByteArrayOutputStream]))
(defn write-cache [cache out-path]
(let [out (ByteArrayOutputStream. 1000000)
writer (transit/writer out :json)]
(transit/write writer cache)
(spit (io/file out-path) (.toString out))))
(defn extract-analysis-cache [res out-path]
(let [cache (read-string (slurp res))]
(write-cache cache out-path)))
(println "Building")
(cljs.analyzer/with-warning-handlers
[(fn [warning-type env extra]
(when (warning-type cljs.analyzer/*cljs-warnings*)
(when-let [s (cljs.analyzer/error-message warning-type extra)]
(binding [*out* *err*]
(println "WARNING:" (cljs.analyzer/message env s)))
(System/exit 1))))]
(api/build (api/inputs "src")
{:output-dir "out"
:output-to "out/main.js"
:optimizations :none
:static-fns true
:optimize-constants false
:dump-core false
:parallel-build true}))
(let [res (io/resource "cljs/core.cljs.cache.aot.edn")
cache (read-string (slurp res))]
(doseq [key (keys cache)]
(write-cache (key cache) (str "out/cljs/core.cljs.cache.aot." (munge key) ".json"))))
(let [res "out/cljs/core$macros.cljc.cache.edn"
cache (read-string (slurp res))]
(doseq [key (keys cache)]
(write-cache (key cache) (str "out/cljs/core$macros.cljc.cache." (munge key) ".json"))))
(extract-analysis-cache "out/clojure/set.cljs.cache.edn" "out/clojure/set.cljs.cache.json")
(extract-analysis-cache "out/clojure/string.cljs.cache.edn" "out/clojure/string.cljs.cache.json")
(extract-analysis-cache "out/clojure/data.cljs.cache.edn" "out/clojure/data.cljs.cache.json")
(extract-analysis-cache "out/clojure/walk.cljs.cache.edn" "out/clojure/walk.cljs.cache.json")
(extract-analysis-cache "out/clojure/zip.cljs.cache.edn" "out/clojure/zip.cljs.cache.json")
(extract-analysis-cache "out/cljs/analyzer.cljc.cache.edn" "out/cljs/analyzer.cljc.cache.json")
(extract-analysis-cache "out/cljs/compiler.cljc.cache.edn" "out/cljs/compiler.cljc.cache.json")
(extract-analysis-cache "out/cljs/env.cljc.cache.edn" "out/cljs/env.cljc.cache.json")
(extract-analysis-cache "out/cljs/js.cljs.cache.edn" "out/cljs/js.cljs.cache.json")
(extract-analysis-cache "out/cljs/pprint.cljs.cache.edn" "out/cljs/pprint.cljs.cache.json")
(extract-analysis-cache "out/cljs/reader.cljs.cache.edn" "out/cljs/reader.cljs.cache.json")
(extract-analysis-cache "out/cljs/repl.cljs.cache.edn" "out/cljs/repl.cljs.cache.json")
(extract-analysis-cache "out/cljs/source_map.cljs.cache.edn" "out/cljs/source_map.cljs.cache.json")
(extract-analysis-cache "out/cljs/source_map/base64.cljs.cache.edn" "out/cljs/source_map/base64.cljs.cache.json")
(extract-analysis-cache "out/cljs/source_map/base64_vlq.cljs.cache.edn" "out/cljs/source_map/base64_vlq.cljs.cache.json")
(extract-analysis-cache "out/cljs/stacktrace.cljc.cache.edn" "out/cljs/stacktrace.cljc.cache.json")
(extract-analysis-cache "out/cljs/test.cljs.cache.edn" "out/cljs/test.cljs.cache.json")
(extract-analysis-cache "out/cljs/test.cljs.cache.edn" "out/cljs/test.cljs.cache.json")
(extract-analysis-cache "out/cljs/tagged_literals.cljc.cache.edn" "out/cljs/tagged_literals.cljc.cache.json")
(extract-analysis-cache "out/cljs/tools/reader/reader_types.cljs.cache.edn" "out/cljs/tools/reader/reader_types.cljs.cache.json")
(extract-analysis-cache "out/cljs/tools/reader/impl/commons.cljs.cache.edn" "out/cljs/tools/reader/impl/commons.cljs.cache.json")
(extract-analysis-cache "out/cljs/tools/reader/impl/utils.cljs.cache.edn" "out/cljs/tools/reader/impl/utils.cljs.cache.json")
(extract-analysis-cache "out/cognitect/transit.cljs.cache.edn" "out/cognitect/transit.cljs.cache.json")
(extract-analysis-cache "out/planck/repl.cljs.cache.edn" "out/planck/repl.cljs.cache.json")
(extract-analysis-cache "out/planck/repl_resources.cljs.cache.edn" "out/planck/repl_resources.cljs.cache.json")
(extract-analysis-cache "out/planck/themes.cljs.cache.edn" "out/planck/themes.cljs.cache.json")
(extract-analysis-cache "out/planck/core.cljs.cache.edn" "out/planck/core.cljs.cache.json")
(extract-analysis-cache "out/planck/io.cljs.cache.edn" "out/planck/io.cljs.cache.json")
(extract-analysis-cache "out/planck/shell.cljs.cache.edn" "out/planck/shell.cljs.cache.json")
(extract-analysis-cache "out/planck/from/io/aviso/ansi.cljs.cache.edn" "out/planck/from/io/aviso/ansi.cljs.cache.json")
(extract-analysis-cache "out/planck/test/ana_api.cljs.cache.edn" "out/planck/test/ana_api.cljs.cache.json")
(extract-analysis-cache "out/planck/test/template.cljs.cache.edn" "out/planck/test/template.cljs.cache.json")
(extract-analysis-cache "out/tailrecursion/cljson.cljs.cache.edn" "out/tailrecursion/cljson.cljs.cache.json")
(println "Done building")
(System/exit 0)