问题
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"}}
]
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.
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.
回答1:
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.
来源:https://stackoverflow.com/questions/12932308/how-to-share-code-between-separate-clojurescripts-in-the-same-project