Tag: clojurescript

在Heroku上的Clojurescript

我喜欢编写Clojure webapps,但是在Heroku这样的平台上使用时,却有着无法接受的启动时间。 有没有人尝试在服务器端使用Clojurescript与节点例如? 这是否改善启动时间?

如何在nodejs中设置clojurescript * print-fn * fn

我正在编译clojurescript到nodejs,我真的想要使用println函数: (println "hello world") 但是,它给了我一个错误 No *print-fn* fn set for evaluation environment 我环顾了networking,但是不清楚应该做什么。 我真的只是想设置*print-fn*到js/console.log但我不知道该怎么做

如何不完整的ClojureScript? (范围)(迭代)等

我正在尝试最近使用ClojureScript而不是Clojure。 当我编译和运行node.js (.log js/console (range 10)) 我有 $ node app { meta: null, start: 0, end: 10, step: 1, __hash: null, 'cljs$lang$protocol_mask$partition1$': 0, 'cljs$lang$protocol_mask$partition0$': 32375006 } 我有点惊讶地看到这个简单的代码不起作用。 这是由于我的具体环境? 我希望如此,如果这是我的问题,请告知。 这里是编译的js: cljs.nodejs = {}; cljs.nodejs.require = require; cljs.nodejs.process = process; cljs.core.string_print = cljs.nodejs.require.call(null, "util").print; var rxcljs = {core:{}}; console.log(cljs.core.range.call(null, 10));

在使用另一个lein项目时使用nodejs运行ClojureScript

我正在写一个名为“gpqgame”的clojurescript程序,它演变了一些代码; 它通过在称为“qgame”的模拟器上运行它来评估一段代码的“准确性”,该模拟器是另一个目录中的一个项目。 到目前为止,我已经手动加载所有的qgame代码到一个repl中,然后使用它来testing我的进化代码。 但是,我希望能够从terminal运行代码,因此我将gpqgame设置为lein项目,并一直尝试使用nodejs。 我立即开始遇到麻烦。 Gpqgame似乎无法加载qgame,我不知道为什么,我已经包含了两个project.clj文件。 我已经尝试加载完整的项目作为一个lib和外部库内的cljs构build,我已经尝试复制qgame的“src”到gpqgame的“src”,同时包括qgame需要的资源库gpqgame。 我的gpqame.core有以下ns声明: (ns gpqgame.core (:require [clojure.string :as st] [qgame.simulator.interpreter :as inter] [qgame.gp.evaluator :as ev] [qgame.simulator.qgates :as qg] [clojure.browser.repl :as repl])) 它包含(enable-console-print!)和(set! *main-cli-fn* -main) 。 每次编译都会成功,但会给出警告:1)在qgame代码中使用未声明的variables2)不允许将关键字和保留字作为未引用的旧的JavaScript中的属性名称 当我运行node out/gpqgame.js ,出现“mathjs is not defined”的引用错误。 我注意到的一件事是qgame使用0.0-2156,而我的gpqgame使用0.0-2913。 如果我将其中一个的版本更改为与另一个版本相同,则不再有效。 有没有一种简单的方法让gpqgame加载整个qgame项目,而不必将其包含在gpqgame项目中? 这是做这件事的最好方法,还是应该把它包含在qgame的src中? 为什么当我这样做时,它不工作,即使我包括它需要的库? 我不确定这与nodejs有多大关系,以及由于我自己的糟糕设置而导致了多less。 任何帮助将不胜感激。 (defproject gpqgame "0.1.0-SNAPSHOT" :description "FIXME: write this!" :url "http://example.com/FIXME" :dependencies [[org.clojure/clojure […]

ClojureScript Electron app __dirname返回nil

我正在用ClojureScript写电子应用程序,并得到这个奇怪的行为: (ns hello-world.core (:require [cljs.nodejs :as nodejs])) (nodejs/enable-util-print!) (def electron (nodejs/require "electron")) (def app (.-app electron)) (defn on-ready [] (prn (js* "__dirname"))) ; => nil (defn -main [& args] (prn (js* "__dirname")) ; => "/Users/alex/source/electron-cljs/out" (.on app "ready" on-ready)) (set! *main-cli-fn* -main) 正如你所看到的,__dirname在-main函数中parsing得很好,但是在我的电子“ready”callback函数中返回nil。 为什么不在callback里面工作?

我怎样才能连接到一个正在运行的节点程序与我的repl

我正在使用Bodil Stokkes节点repl https://github.com/bodil/cljs-noderepl 。 开始是非常容易的。 正如文档中所述。 现在我想连接我的正在运行的节点程序到repl。 但我不知道如何做到这一点。 有谁能给我一步一步的指示。 我想要做的是 node out/main.js =>启动我的节点进程 lein trampoline noderepl =>这应该以某种方式连接到main.js中的进程 可选的,如果我可以从node-repl中启动/访问我的主程序,我会很高兴。

如何在clojurescript的node.js模块中调用javascript?

我希望在ClojureScript中使用Coinbase Bitcoin Exchange node.js API 。 目标是复制页面上的第一个JavaScript示例: var CoinbaseExchange = require('coinbase-exchange'); var publicClient = new CoinbaseExchange.PublicClient(); 但是在我的下面的代码中,我已经开始尝试访问PublicClient了: (ns plutus.core (:require [cljs.nodejs :as nodejs])) (def coinb (nodejs/require "coinbase-exchange")) (nodejs/enable-util-print!) (defn -main [& args] (def pc (js/PublicClient.))) (println pc)) (set! *main-cli-fn* -main) 这会抛出一个ReferenceError: PublicClient is not defined ,尽pipe我也尝试过(以及类似的变化): (def pc (. coinb (PublicClient))) (def pc (.PublicClient coinb)) […]

如何将Macchiato clojurescript应用程序部署到Heroku免费帐户?

我尝试通过以下命令创buildMacchiato(ClojureScript模板)的空白应用程序: lein new macchiato abc cd abc git init heroku create git add –all git commit -m "Initial" git push heroku master heroku run lein package 但应用程序崩溃。 我应该怎么做免费的Heroku上运行Macchiato / ClojureScript空白应用程序? 来自Heroku的一些日志: 2017-09-20T14:20:18.982364+00:00 heroku[web.1]: Starting process with command `node target/release/abc.js` 2017-09-20T14:20:21.393478+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them. 2017-09-20T14:20:23.735706+00:00 app[web.1]: […]

如何在Node.js上运行ClojureScripts Om?

我试图解决,如果我可以在Node.js上使用Om来生成HTML。 我已经能够在Node.js上运行ClojureScript ,显然React可以在Node.js上运行 。 根据基本指南,我创build了一个Leiningen项目 lein new figwheel om-tut — –om 修改project.clj文件启动如下 (defproject om-tut "0.1.0-SNAPSHOT" :description "FIXME: write this!" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2850"] [figwheel "0.2.5-SNAPSHOT"] [org.clojure/core.async "0.1.346.0-17112a-alpha"] [sablono "0.3.4"] [org.omcljs/om "0.8.8"]] :plugins [[lein-cljsbuild "1.0.4"] [lein-figwheel "0.2.5-SNAPSHOT"] [lein-npm "0.4.0"]] :source-paths ["src"] :clean-targets ^{:protect false} ["resources/public/js/compiled" "out/server" […]

使用ClojureScript项目中的Node.js库

我想在基于Figwheel的ClojureScript应用程序中使用基于Node.js的组件( https://github.com/leandrowd/react-responsive-carousel )。 不幸的是,我找不到一个“standalone”,打包Javascript文件与react-responsive-carousel 。 由于我的应用程序不是由Node.js运行,它不能require等。 有没有一种优雅的方式来重用ClojureScript中的Node.js库,或者是将任何Node.js库打包到独立文件中的解决scheme?