如何在同一项目中的单独clojurescripts之间共享代码 [英] How to share code between separate clojurescripts in the same project
问题描述
我有一个项目,编译2个脚本应用程序的2页:
I have a project that compiles 2 scripts used in 2 pages of the app:
:cljsbuild {:builds [{:source-path "src-cljs/search",
:compiler {:output-to "resources/public/cljs/search.js" }}
{:source-path "src-cljs/view",
:compiler { :output-to "resources/public/cljs/view.js"}}
]
我有两个脚本的共同的代码。如何分享这段代码?我发现的唯一的方法是通过一个单独的Clojure项目 - 我执行'lein安装'它,它可用于我的ClojuresScript代码作为任何其他第三方库。
I have code common for both scripts. How to share this code? The only way I have found is through a separate Clojure project - I execute 'lein install' on it and it is available to my ClojuresScript code as any other third-party library.
我注意到了交叉,但他们是用于在Clojure和ClojureScript之间共享代码。我不需要在Clojure中的共享代码。所以我可以使用交叉,但这将留给我一些不需要的Clojure代码在末端jar。
I've noticed the crossovers, but they are for sharing code between Clojure and ClojureScript. I don't need the shared code in Clojure. So I could use crossovers but that would leave me with some unneeded Clojure code in the end jar. Not a big issue but still not good.
推荐答案
在此文章我提供了同样的问题。你的解决方案是我所说的易于复杂的解决方案,因为重复。第二个我称之为简单容易应该是你正在寻找的。
In this article I afforded the same issue. You're solution is the one I called "Easy made complex" solution, because of duplication. The second one which I called the "Simple made easy" should be the one you're looking for.
这篇关于如何在同一项目中的单独clojurescripts之间共享代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!