Trying to use re-frame-10x (was re-frame-trace) with descjop (electron) project
我正在尝试使用重新框架和电子的组合来建立一个项目,我想安装重新框架10倍,以便我可以轻松观看app-db的某些部分。我以前将其用于通过Google chrome访问的常规clojurescript / re-frame项目,但尚未使用电子。我充满希望,因为我相信电子在引擎盖下使用与铬基本相同的代码。
我按照re-frame-10x github页面上的设置说明进行操作,似乎一切正常。但是我无法调用10x窗口。
这是我的project.clj文件的一部分,尤其是clojurescript开发人员构建的文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | :cljsbuild {:builds {:dev-main {:source-paths ["src"] :incremental true :jar true :assert true :compiler {:output-to"app/dev/js/cljsbuild-main.js" :externs ["app/dev/js/externs.js" "node_modules/closurecompiler-externs/path.js" "node_modules/closurecompiler-externs/process.js"] :warnings true :elide-asserts true :target :nodejs :output-dir"app/dev/js/out_main" :optimizations :simple :pretty-print true :output-wrapper true :closure-defines {"re_frame.trace.trace_enabled_QMARK_" true} :preloads [day8.re-frame-10x.preload] :main"anh.core" }} :dev-front {:source-paths ["src_front""src_front_profile/anh_front/dev"] :incremental true :jar true :assert true :compiler {:output-to"app/dev/js/front.js" :externs ["app/dev/js/externs_front.js"] :warnings true :elide-asserts true :optimizations :none :output-dir"app/dev/js/out_front" :pretty-print true :output-wrapper true }} |
请注意,有2个版本。 (figwheel-status)告诉我它正在监视和重新编译dev-front。 dev-main包含指向re-frame-10x所需的main的指针。
Clojurescript已升级到最新版本" 1.10.64",一切看起来都很好,当repl启动时(使用emacs的插件)或clojurescript repl启动时,没有错误消息。
re-frame-10x窗口仍然没有迹象。当我在应用程序窗口中按ctrl-h时,它应该出现。
这条线下面是我尝试的方法。可能无关紧要。
滚动浏览clojure repl消息,我发现在启动cljs repl时,它遇到了re-frame-10x的某种问题:
1 2 3 4 5 6 7 8 9 10 11 | user> Figwheel: Starting server at http://0.0.0.0:3441 Figwheel: Watching build - dev-front Figwheel: Cleaning build - dev-front Compiling"app/dev/js/front.js" from ["src_front""src_front_profile/anh_front/dev"]... Failed to compile"app/dev/js/front.js" in 10.853 seconds. ---- Could not Analyze app/dev/js/out_front/day8/re_frame_10x/subs.cljs ---- No such namespace: cljs.spec.alpha, could not locate cljs/spec/alpha.cljs, cljs/spec/alpha.cljc, or Closure namespace"cljs.spec.alpha" ---- Analysis Error : Please see app/dev/js/out_front/day8/re_frame_10x/subs.cljs ---- Launching ClojureScript REPL for build: dev-front |
知道这意味着什么吗?我没有使用cljs.spec(但是),但似乎编译器正在寻找它。
这是project.clj文件的一部分,具有re-frame-10x要求的修改,尤其是有关cljsbuild部分的编译器部分中的闭包定义,预加载和链接到main:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | :dev-front {:source-paths ["src_front""src_front_profile/anh_front/dev"] :incremental true :jar true :assert true :compiler {:output-to"app/dev/js/front.js" :externs ["app/dev/js/externs_front.js"] :warnings true :elide-asserts true :optimizations :none :output-dir"app/dev/js/out_front" :pretty-print true :output-wrapper true :closure-defines {"re_frame.trace.trace_enabled_QMARK_" true} :preloads [day8.re-frame-10x.preload] :main"anh.core" }} |
更新:
这有助于:
没有这样的名称空间:clojurescript项目设置中的clojure.spec.alpha
按照建议,我将clojurescript升级到了具有所需规范内容的最新版本,并且在启动cljs repl时repl显示了不同的错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Failed to load resource: net::ERR_FILE_NOT_FOUND cljs_deps.js Failed to load resource: net::ERR_FILE_NOT_FOUND base.js:677 goog.require could not find: day8.re_frame_10x.preload goog.logToConsole_ @ base.js:677 base.js:711 Uncaught Error: goog.require could not find: day8.re_frame_10x.preload at Object.goog.require (base.js:711) at index.html:11 base.js:677 goog.require could not find: anh.core goog.logToConsole_ @ base.js:677 base.js:711 Uncaught Error: goog.require could not find: anh.core at Object.goog.require (base.js:711) at index.html:11 base.js:677 goog.require could not find: anh_front.init goog.logToConsole_ @ base.js:677 base.js:711 Uncaught Error: goog.require could not find: anh_front.init at Object.goog.require (base.js:711) at index.html:12 |
这只是找不到主要功能。 project.clj文件指定2个dev构建,dev-front和dev-main。我在错误的部分输入了clojurescript编译器选项。将它们移到正确的位置可以消除错误,但是当我按ctrl-h时,仍然不会显示re-frame-10x窗口。
解决此问题的关键在于将其正确构建。 Descjop有2个开发版本,一个用于应用程序本身(dev-main),一个用于窗口(dev-front)。 Dev-main可以并且可能应该单独放置。所做的更改需要在开发人员内部进行。
第1步
将开发者前端版本转换为:optimizations none。这是10帧重新帧的要求之一。为此,需要在profile.clj的cljsbuild部分的:dev-front:compiler部分下添加以下内容:
1 2 | :main"setup-front.init" :asset-path"js/out_front" |
然后可以将html文件简化为" setup-front.init",它将为您加载必要的内容。像这样:
1 2 3 4 5 6 7 8 9 10 11 | <body> <p> Minimum app does not work. </p> <script type="text/javascript" src="js/front.js" charset="utf-8"> </body> |
第2步
升级!默认情况下,Descjop使用较旧的clojurescript版本,该版本不提供re-frame-10x使用的某些功能。 org.clojure / clojurescript" 1.10.64"为我工作。
之后,可以遵循re-frame-10x的说明,它应该可以正常工作。简而言之,将以下内容添加到cljsbuild部分:
1 2 | :closure-defines {"re_frame.trace.trace_enabled_QMARK_" true} :preloads [day8.re-frame-10x.preload] |
并将其添加到依赖项。最好去:profiles:dev部分。不过,请查看说明或Clojars以获取最新版本:
1 | [day8.re-frame/re-frame-10x"0.2.1-SNAPSHOT"] |
使用这些更改的非常基本的hello-world的源代码可以在github上找到
感谢Mike Callahan提供此解决方案的要点。