                        (remove #(str/includes? js (str "(\"" % "\")")))
                        (into #{}))
 
-                  sw
-                  (StringWriter.)
-
-                  ;; for sourcesContent
-                  _ (.addSourceFile source-map source-file)
-                  _ (.appendTo source-map sw output-name)
-
                   sm-json
-                  (.toString sw)
+                  (when generate-source-map?
+                    (let [sw (StringWriter.)]
+                      ;; for sourcesContent
+                      (.addSourceFile source-map source-file)
+                      (.appendTo source-map sw output-name)
+                      (.toString sw)))
 
                   deps
                   (data/deps->syms state rc)


        co-opts
        (merge
          {:source-map true
           ;; :whitespace or :simple work but some patterns really require the DCE done by :simple
           ;; eg some conditional imports done by react&friends
           :optimizations :simple
           :pretty-print false
           :pseudo-names false
           ;; es6+ is transformed by babel first

                  (into #{} (remove removed-requires) deps)

                  output
                  (-> {:resource-id resource-id
                       :js js
                       :source (.getCode source-file)
                       :removed-requires removed-requires
                       :actual-requires actual-requires
                       :properties (into #{} (-> property-collector (.-properties) (.get name)))
                       :compiled-at (System/currentTimeMillis)}
                      (cond->
                        generate-source-map?
                        (assoc :source-map-json sm-json)))]

              (assoc-in state [:output resource-id] output)
              ))
