How to share code between separate clojurescripts in the same project

浪子不回头ぞ 提交于 2019-12-14 03:10:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!