Search code examples
leiningengoogle-closure-compilerclojurescriptfigwheel

ClojureScript cljsbuild doesn't load dependencies without optimisations


I am trying to use figwheel in my ClojureScript build.

It works with lein cljsbuild auto already, but I have to put :optimisations :whitespace.

Otherwise I get a message in the browser :

Uncaught ReferenceError: goog is not defined

However figwheel require :optimisations :none to run. Here is the part of my leiningen file :

:cljsbuild {
          :builds
          [{:id "dev"
            :source-paths ["src/cljs"]

            :figwheel { :websocket-host "localhost"
                       ;;:on-jsload "example.core/fig-reload"
                       :autoload true
                       :heads-up-display true
                       :load-warninged-code true
                       ;;:url-rewriter "example.core/fig-url-rewrite"
                       }

            :compiler {;; :main
                       :output-to  "resources/public/js/gdb/gdb.js"
                       :output-dir "resources/public/js/gdb/cljsbuild-dev"
                       ;;:asset-path "js/out"

                       :optimizations :none
                       :source-map "resources/public/js/gdb/gdb.js.map"
                       :pretty-print true}}]}

What is missing for me to get the missing dependencies ?


Solution

  • It turns out this is a classic case of RTFM. The answer was in the ClojureScript quickstart guide.

    Specifically, I had to add a :main field, as specified in the Less Boilerplate section :

    :main "example.core"