       (.getConstructor ES6ModuleLoader
         (into-array java.lang.Class
                     [AbstractCompiler java.lang.String])))
- (def can-convert-js-module? true)
- (def can-convert-js-module? false))
+ (def can-convert-commonjs? true)
+ (def can-convert-commonjs? false))
+
+(compile-if
+ (and can-convert-commonjs?
+      (.getConstructor TransformAMDToCJSModule
+        (into-array java.lang.Class
+                    [AbstractCompiler])))
+ (def can-convert-amd? true)
+ (def can-convert-amd? false))
 
 ;; Closure API
 ;; ===========

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

          es6-loader (ES6ModuleLoader. closure-compiler module-root)
          cjs (ProcessCommonJSModules. closure-compiler es6-loader)
          ^Node root (.parse closure-compiler source-file)]
      (compile-if can-convert-amd?
        (.process (TransformAMDToCJSModule. closure-compiler) nil root))
      (.process cjs nil root)
      (.toSource closure-compiler root))))

