        (every? #(str/starts-with? (str %) "goog.") provides)
        ))
 
-(defn flush-unoptmized-module!
+(defn flush-unoptimized-module!
   [{:keys [dev-inline-js public-dir public-path unoptimizable] :as state}
    {:keys [default js-name name prepend prepend-js append-js sources web-worker] :as mod}]
   (let [inlineable-sources

   (with-logged-time
     [state {:type :flush-sources
             :source-names source-names}]
     (doseq [{:keys [type name input last-modified] :as src}
             (->> source-names
                  (map #(get-in state [:sources %])))
             :let [target (io/file public-dir cljs-runtime-path name)]

             ;; skip files we already have since source maps are kinda expensive to generate
             :when (or (not (.exists target))
                       (zero? last-modified)
                       (> (or (:compiled-at src) ;; js is not compiled but maybe modified
                              last-modified)
                          (.lastModified target)))]

       (io/make-parents target)

       (case type
         ;; cljs needs to flush the generated .js, for source-maps also the .cljs and a .map
         :cljs
         (do (let [{:keys [source-map js-name output]} src
                   js-target (io/file public-dir cljs-runtime-path js-name)]

               (when (nil? output)
                 (throw (ex-info (format "no output for resource: %s" js-name) src)))

               ;; must not modify output in any way, will mess up source maps otherwise
               (spit js-target output)

               ;; source-map on the resource is always generated
               ;; only output it though if globally activated
               (when (and source-map (:source-map state))
                 (let [source-map-name (str js-name ".map")]
                   (spit (io/file public-dir cljs-runtime-path source-map-name)
                     (sm/encode
                       {name source-map}
                       {:lines
                        (-> (StringReader. output)
                            (BufferedReader.)
                            (line-seq)
                            (count))
                        :file js-name
                        :preamble-line-count 0}))
                   )))

             ;; spit original source, cljs needed for source maps
             (spit target @input))

         ;; js just needs itself
         ;; FIXME: needs to flush more when js processing is added
         :js
         (do (spit target (:output src))
             ;; foreign libs should play nice with goog require/import and tell what they provide
             (when (:foreign src)
               (spit target (make-foreign-js-source src) :append true)
               ))

         (throw (ex-info "cannot flush" (dissoc src :input :output)))
         ))

     state)))



;; FIXME: manifest should be custom step

    (flush-manifest public-dir build-modules)

    (doseq [mod build-modules]
      (flush-unoptimized-module! state mod))

    state
    ))
