[英]How to improve the workflow of editing dependencies and watching the changes on a main Clojure/ClojureScript dynamic web app project?
I have been using Clojure, ClojureScript, lein, shadow-cljs, Emacs, and CIDER to work on a Clojure/ClojureScript dynamic web app project.我一直在使用 Clojure、ClojureScript、lein、shadow-cljs、Emacs 和 CIDER 来处理 Clojure/ClojureScript动态Z2567A5EC9705EB7AC2C984033E0618D 项目。
There is the main repository, let's call it principal
.有主存储库,我们称它为
principal
。 And also a supporting repository, let's call it supporting
.还有一个支持存储库,我们称它为
supporting
.
Ok.好的。 On my local
~/projects
folder, I have ~/projects/principal/
and also ~/projects/supporting
.在我的本地
~/projects
文件夹中,我有~/projects/principal/
和~/projects/supporting
。
As the names suggest, supporting
is a dependency of principal
.顾名思义,
supporting
是principal
的依赖项。
Currently, the workflow to work on both repositories is extremely painful .目前,在这两个存储库上工作的工作流程非常痛苦。 I would like to know if there is a better way.
我想知道是否有更好的方法。
This is the current workflow:这是当前的工作流程:
1 - Build the project on principal
with: cider-jack-in-cljs,
I choose shadow-cljs
, then shadow
for REPL type, and app
for build option. 1 - 使用以下命令在
principal
上构建项目: cider-jack-in-cljs,
我选择shadow-cljs
,然后选择shadow
作为 REPL 类型,并选择app
作为构建选项。
2 - If principal
needs a tweak on the interfaces of supporting
, it is not possible to edit supporting
directly and watch the changes live. 2 - 如果
principal
需要对supporting
接口进行调整,则无法直接编辑supporting
并实时观看更改。
3 - Thus, I copy the function to be tweaked on supporting
and paste it on principal
. 3 - 因此,我复制 function 以调整
supporting
并将其粘贴到principal
上。 Then, I tweak namespaces and some names.然后,我调整命名空间和一些名称。 I do the tweak and adjust the invocation.
我进行调整并调整调用。 More importantly, I am able to watch the changes on the live app being displayed on localhost.
更重要的是,我能够看到本地主机上显示的实时应用程序的变化。
4 - Everything seems to work fine after some tests. 4 - 经过一些测试,一切似乎都正常。
5 - Now, it is time to edit things on supporting
repository. 5 - 现在,是时候在
supporting
存储库上编辑内容了。 This time, with the proper namespaces and names.这一次,使用正确的命名空间和名称。 Also, it is time to remove the temporary duplicate on
main
此外,是时候删除
main
上的临时副本了
6 - It is not possible to watch the changes on supporting
without re-building the whole thing on principal
after doing a new lein install
on supporting
. 6 - 在对
supporting
进行新的lein install
之后,如果不重新构建整个principal
,就不可能看到supporting
的变化。
7 - After a lein install
on supporting, quitting watch app
and re-doing the entire build of principal
, I can see the app live and check if everything is fine. 7 - 在支持、退出
watch app
并重新构建principal
的lein install
后,我可以看到应用程序实时并检查是否一切正常。
Is there a better way to achieve the same result?有没有更好的方法来达到相同的结果?
As far as shadow-cljs is concerned it'll always watch files.就 shadow-cljs 而言,它总是会监视文件。 The only rule is that it doesn't watch files in
.jar
, since those can't change.唯一的规则是它不监视
.jar
中的文件,因为这些文件无法更改。 So, all you need is telling shadow-cljs where it can find the files.所以,你只需要告诉 shadow-cljs 它在哪里可以找到文件。
You didn't specify how you are managing dependencies, so I'm going to assume you just have them in shadow-cljs.edn
:dependencies
.您没有指定如何管理依赖项,所以我假设您只是将它们放在
shadow-cljs.edn
:dependencies
中。
One way to have shadow-cljs
watch the supporting
files is just adding the source paths directly.让
shadow-cljs
监视supporting
文件的一种方法是直接添加源路径。
{:source-paths ["src/main" "../supporting/src/main"]
:dependencies [[your/supporting "0.1.0"]]
:builds ...}
You keep the dependency as well, but by including the source path entry you ensure those files are used over the files in the installed .jar
.您也保留了依赖关系,但是通过包含源路径条目,您可以确保这些文件用于已安装的
.jar
中的文件。 You keep the declared supporting
dependency so its dependencies are picked up properly.您保留声明的
supporting
依赖项,以便正确获取其依赖项。
Another option is using lein
checkouts
and managing dependencies in project.clj
.另一种选择是在
project.clj
中使用lein
checkouts
和管理依赖项。 lein
can also use the trick above by adding source paths outside the project. lein
还可以通过在项目外部添加源路径来使用上述技巧。
Another option is using deps.edn
to manage dependencies and declaring the supporting
dep via :local/root
.另一种选择是使用
deps.edn
来管理依赖项并通过:local/root
声明supporting
的 dep。
{:paths ["src/main"]
:deps {your/supporting {:local/root "../supporting"}}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.