                             merged)
                           (assoc merged path (get closure-source-map path))))
                       merged)))
-                (spit (io/file name)
-                      (sm/encode merged
-                                 {:preamble-line-count preamble-line-count
-                                  :lines (+ (:lineCount sm-json) preamble-line-count 2)
-                                  :file (:file sm-json)
-                                  :output-dir (util/output-directory opts)
-                                  :source-map-path (:source-map-path opts)
-                                  :source-map (:source-map opts)
-                                  :relpaths relpaths}))))))
+                (spit
+                  (io/file name)
+                  (sm/encode merged
+                    {:preamble-line-count (+ preamble-line-count
+                                             (or (:foreign-deps-line-count opts) 0))
+                     :lines (+ (:lineCount sm-json) preamble-line-count 2)
+                     :file (:file sm-json)
+                     :output-dir (util/output-directory opts)
+                     :source-map-path (:source-map-path opts)
+                     :source-map (:source-map opts)
+                     :relpaths relpaths}))))))
         source)
       (report-failure result))))
 

                                   [(-compile (io/resource "cljs/nodejscli.cljs") all-opts)]))))
                 optim (:optimizations all-opts)
                 ret (if (and optim (not= optim :none))
                       (do
                         (when-let [fname (:source-map all-opts)]
                           (assert (string? fname)
                             (str ":source-map must name a file when using :whitespace, "

(defn add-header [opts js]
  (str (make-preamble opts) js))

(defn foreign-deps-str [sources]
  (letfn [(to-js-str [ijs]
            (let [url (or (:url-min ijs) (:url ijs))]
              (slurp url)))]
    (apply str (map to-js-str sources))))

(defn add-wrapper [{:keys [output-wrapper] :as opts} js]
  (if output-wrapper
