   [opts]
   (let [js-modules (filter :module-type (:foreign-libs opts))]
     (reduce (fn [opts {:keys [file module-type] :as lib}]
-              (if (= module-type :commonjs)
+              (if (or (and (= module-type :commonjs) can-convert-commonjs?)
+                      (and (= module-type :amd) can-convert-amd?))
                 (let [module-name (ProcessCommonJSModules/toModuleName file)
                       ijs (write-javascript opts (deps/load-foreign-library lib))]
                   (doseq [provide (:provides ijs)]

(defmulti convert-js-module
  "Takes a JavaScript module and rewrites it into a Google Closure-compatible
  form. Returns the source of the new module as a single string."
  :module-type)

(compile-if can-convert-js-module?
  (defmethod convert-js-module :commonjs [js]
    (let [js-file (:file js)
          path (.getParent (io/file js-file))

              Result JSError CheckLevel DiagnosticGroups
              CommandLineRunner AnonymousFunctionNamingPolicy
              JSModule JSModuleGraph SourceMap ProcessCommonJSModules
              ES6ModuleLoader AbstractCompiler TransformAMDToCJSModule]
           [com.google.javascript.rhino Node]
           [java.security MessageDigest]
           [javax.xml.bind DatatypeConverter]
