ClojureScript cljsbuild在没有优化的情况下不会加载依赖项

nha*_*nha 1 google-closure-compiler leiningen clojurescript figwheel

我想在我的ClojureScript构建中使用figwheel.

lein cljsbuild auto已经合作,但我必须把它:optimisations :whitespace.

否则我在浏览器中收到一条消息:

Uncaught ReferenceError: goog is not defined
Run Code Online (Sandbox Code Playgroud)

然而,figwheel需要:optimisations :none运行.这是我的leiningen文件的一部分:

: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}}]}
Run Code Online (Sandbox Code Playgroud)

我缺少什么来获取缺少的依赖项?

nha*_*nha 6

事实证明这是RTFM的经典案例.答案在ClojureScript快速入门指南中.

具体来说,我必须添加一个:main字段,如Less Boilerplate部分中所指定的:

:main "example.core"
Run Code Online (Sandbox Code Playgroud)

  • 仅供参考:这一条评论为我节省了大约5个小时的痛苦.感谢x 10,即使你已经解决了问题,也要把它放好. (2认同)