File tree 1 file changed +17
-5
lines changed
1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change 32
32
[cljs.tools.reader :as reader]
33
33
[cljs.tools.reader.reader-types :as readers]
34
34
[cljs.reader :as edn]))
35
- #? (:clj (:import [java.io File Reader PushbackReader FileOutputStream]
35
+ #? (:clj (:import [java.io File Reader PushbackReader FileOutputStream FileInputStream ]
36
36
[java.net URL]
37
37
[java.lang Throwable]
38
38
[clojure.lang Namespace Var LazySeq ArityException]
2801
2801
core-cache
2802
2802
(let [target-file (util/to-target-file output-dir ns-info
2803
2803
(util/ext (:source-file ns-info)))]
2804
- (io/file (str target-file " .cache.edn" )))))))
2804
+ (if @transit
2805
+ (io/file (str target-file " .cache.json" ))
2806
+ (io/file (str target-file " .cache.edn" ))))))))
2805
2807
2806
2808
#?(:clj
2807
2809
(defn requires-analysis?
2814
2816
(requires-analysis? src cache output-dir)))
2815
2817
([src cache output-dir]
2816
2818
(cond
2819
+ (util/url? cache)
2820
+ (let [path (.getPath ^URL cache)]
2821
+ (if (or (.endsWith path " cljs/core.cljs.cache.aot.edn" )
2822
+ (.endsWith path " cljs/core.cljs.cache.aot.json" ))
2823
+ false
2824
+ (throw (Exception. (str " Invalid anlaysis cache, must be file not URL " cache)))))
2825
+
2817
2826
(and (util/url? cache)
2818
- (or (.endsWith (.getPath ^URL cache) " cljs/core.cljs.cache.aot.edn" )
2819
- (.endsWith (.getPath ^URL cache) " cljs/core.cljs.cache.aot.json" )))
2827
+ (.endsWith (.getPath ^URL cache) " cljs/core.cljs.cache.aot.json" ))
2820
2828
false
2821
2829
2822
2830
(and (util/file? cache)
2912
2920
{:restore false
2913
2921
:analyze-deps true
2914
2922
:load-macros true }))
2915
- cached-ns (edn/read-string (slurp cache))]
2923
+ ext (util/ext cache)
2924
+ cached-ns (case ext
2925
+ " edn" (edn/read-string (slurp cache))
2926
+ " json" (let [{:keys [reader read]} @transit]
2927
+ (read (reader (FileInputStream. ^File cache) :json ))))]
2916
2928
(when (or *verbose* (:verbose opts))
2917
2929
(util/debug-prn " Reading analysis cache for" (str res)))
2918
2930
(swap! env/*compiler*
You can’t perform that action at this time.
0 commit comments