我正在关注 Shadow-cljs Quick Start 有关项目最小示例的文档。这是链接。
最初,我有这个
shadow-cljs.edn
文件:
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dev-http {8080 "public"}
:dependencies
[]
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn acme.frontend.app/init}}
}}}
在
/Users/pedro/projects/acme-app/src/main/acme/frontend/app.cljs
中,我还有:
(ns acme.frontend.app)
(defn init []
(println "Hello World"))
我可以使用以下命令构建并观看它:
$ npx shadow-cljs compile frontend
shadow-cljs - config: /Users/pedro/projects/acme-app/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
[:frontend] Compiling ...
[:frontend] Build completed. (79 files, 0 compiled, 0 warnings, 4.88s)
我一直在添加依赖项,例如:
:dependencies [[day8.re-frame/re-frame-10x "1.2.1"]
[proto-repl "0.3.1"]
[re-frame "1.2.0"]
[com.degel/re-frame-firebase "0.9.6-SNAPSHOT"]
[bidi "2.1.5"]
[re-com "2.13.2-106-180ea1f-SNAPSHOT-TALLYFOR"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[com.pupeno/free-form "0.6.0"]
[binaryage/dirac "RELEASE"]
[hickory "0.7.1"]
[cljs-hash "0.0.2"]
[medley "1.2.0"]]
但是,构建在
files
、compiled
和 warnings
方面没有改变。只是时间发生了一点变化 - 时间可能有点随机/随机(79 files, 0 compiled, 0 warnings, 5.59s)
。
依赖项真的已编译吗?我如何知道依赖项是否也已编译?
如果正在编译,为什么文件数量保持不变?
Obs.:请注意,我没有调用依赖项内使用的函数 - 并且我不想出于调试原因调用它们。
添加
:dependencies
作用很小,它们不会自行编译。它们仅在类路径上可用。
只有当您将它们添加到文件的
:require
形式中的 ns
或在 REPL 中动态添加 require
时,它们才会被编译和加载。如果没有明确的请求(即:require
)来加载它们,它们只是未使用的被动资源。