Uploaded image for project: 'ClojureScript'
  1. CLJS-1288

compiler doesn't emit "goog.require" for foreign library when optimization level is not set

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Completed
    • Affects versions: 0.0-3269
    • Fix versions: None
    • Labels:
    • Patch:
      Code

      Description

      When the optimization level is not set explicitly, meaning that :none will be used as a default, the compiler doesn't emit a goog.require for foreign libraries. An example project reproducing the problem can be found here: https://github.com/MNeise/hello_world.

      From my understanding of the code, the compiler environment gets created with the initial options and doesn't get updated with the default optimization level when the options don't include an optimization level. The following check in the load-libs function in the compiler.cljc file then fails, because optimizations is nil.

      compiler.cljc
            (cond
              (ana/foreign-dep? lib)
              (let [{:keys [target optimizations]} (get @env/*compiler* :options)]
                ;; we only load foreign libraries under optimizations :none
                (when (= :none optimizations)
                  (if (= :nodejs target)
                    ;; under node.js we load foreign libs globally
                    (let [{:keys [js-dependency-index options]} @env/*compiler*
                          ijs-url (get-in js-dependency-index [(name lib) :url])]
                      (emitln "cljs.core.load_file(\""
                        (str (io/file (util/output-directory options) (util/get-name ijs-url)))
                        "\");"))
                    (emitln "goog.require('" (munge lib) "');"))))
      
      

        Attachments

          Activity

            People

            • Assignee:
              mneise Maria Geller
              Reporter:
              mneise Maria Geller
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: