               source-text
               (if expression? "Expression" "File")
               (merge
-                {:ns           @current-ns
-                 :source-map   false
-                 :verbose      (:verbose @app-env)
-                 :cache-source (fn [x cb]
-                                 #_(when (and path (:source x))
-                                     (js/PLANCK_CACHE path (:source x) nil))
-                                 (cb {:value nil}))}
-                (when expression?
+                {:ns         @current-ns
+                 :source-map false
+                 :verbose    (:verbose @app-env)}
+                (if expression?
                   {:context       :expr
-                   :def-emits-var true}))
+                   :def-emits-var true}
+                  (when (:cache-path @app-env)
+                    {:cache-source (fn [x cb]
+                                     (when (and (= "File" (:name x)) (:source x))
+                                       (let [source (:source x)
+                                             [file-namespace relpath] (extract-cache-metadata-mem source-text)]
+                                         (js/PLANCK_CACHE (cache-prefix-for-path relpath) source
+                                           (when file-namespace
+                                             (cljs->transit-json (get-in @st [:cljs.analyzer/namespaces file-namespace]))))))
+                                     (cb {:value nil}))})))
               (fn [{:keys [ns value error] :as ret}]
                 (if expression?
                   (when-not error


(defn ns-form? [form]
  (and (seq? form) (= 'ns (first form))))

(def special-doc-map
  '{.     {:forms [(.instanceMethod instance args*)

(defn- cache-prefix-for-path [path]
  (str (:cache-path @app-env) "/" (munge path)))

(defn- extract-cache-metadata [source]
  (let [file-namespace (extract-namespace source)
        relpath (if file-namespace
                  (cljs/ns->relpath file-namespace)
                  "cljs/user")]
    [file-namespace relpath]))

(def extract-cache-metadata-mem (memoize extract-cache-metadata))

(defn caching-js-eval
  [{:keys [path name source cache]}]
  (when (and path source cache (:cache-path @app-env))
