如何在不同的clojurescript项目中使用公共依赖项? [英] How to use common dependencies in different clojurescript projects?

查看:83
本文介绍了如何在不同的clojurescript项目中使用公共依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个clojurescript项目.它是一种试剂成分.现在,我想在其他clojurescript项目中使用此组件.那就是我的工作:我编译了cljs项目,然后将结果编译文件放到其他项目的js文件夹中.此外,我需要index.html中的该文件.最后,我从cljs文件中调用我的组件

I wrote a clojurescript project. It is a reagent component. Now i want to use this component in other clojurescript project. That is what i do: I compiled my cljs project and then i put a result compiled file to js folder in other project. Further i require that file from index.html. At the end i invoke my component from cljs file

(.slider-view (.-views js/swipe) (clj->js [[:p "1"]
                                           [:p "2"]
                                           [:p "3"]]))

,并且有效.但是我有一个问题.我的项目和连接组件的项目有共同的要求.例如React和ReactDOM.如何从我的项目中排除这两个引用,然后将其与另一个项目连接?有替代方法吗?例如,直接从另一个cljs项目中要求cljs名称空间

and it works. But i have a question. My project and project where i connect my component have common requirements. For example React and ReactDOM. How to exclude this two references from my project and then connect it from another project? Is there alternative approaches? For example require cljs namespace from another cljs project directly

推荐答案

即使您可以阻止JavaScript库被两次包含,您仍然会有ClojureScript标准库的巨大块被编译两次.如您所建议,您将希望将第一个项目放在第二个项目的类路径上(通过将其添加到project.clj或等效项目中),然后直接包含该名称空间.

Even if you could prevent JavaScript libraries from being included twice, you will still have huge chunks of the ClojureScript standard library compiled in twice. As you suggested, you will want to put your first project on the classpath of your second project (by adding it to your project.clj or equivalent) and then include that namespace directly.

这篇关于如何在不同的clojurescript项目中使用公共依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆