                              (str ":source-map must name a file when using :whitespace, "
                                   ":simple, or :advanced optimizations"))
                            (doall (map #(source-on-disk all-opts %) js-sources)))
-                         (if (:modules opts)
+                         (if (:modules all-opts)
                            (->>
                              (apply optimize-modules all-opts js-sources)
                              (output-modules all-opts))

        sources (if (= :whitespace (:optimizations opts))
                  (cons "var CLOSURE_NO_DEPS = true;" sources)
                  sources)
        modules (build-modules sources (:modules opts))
        ^List inputs (map (comp :closure-module second) modules)
        ^Result result (.compileModules closure-compiler externs inputs compiler-options)]
    (if (.success result)

                        sources)))
        [sources' modules]
        (reduce
          (fn [[sources ret] [name {:keys [entries output-to depends-on] :as module-desc}]]
            (assert (or (= name :cljs-base) (not (empty? entries)))
              (str "Module " name " does not define any :entries"))
            (let [js-module (JSModule. (clojure.core/name name))
                  [sources' module-sources]
                  ;; compute inputs for a closure module
                  ;; as well as sources difference
