使用Rhino从命令行执行编译的ClojureScript [英] Execute compiled ClojureScript from the commandline with Rhino
问题描述
我知道ClojureScript可以在JavaScript REPL中执行,也可以编译成JavaScript,然后在浏览器中运行。我找不到一个方法来使用它在服务器端与Rhino。这里是我的思维方式,我有一个简单的源文件:
(ns simple.hello)
(printlnHello,world)
我编译为 hello .js
。我尝试运行
java -jar js.jar out / goog / base.js out / goog / deps.js out / hello.js
没有发生任何事情。
这对我有用:/ p>
src / app.js:
(ns simple.app)
(ns hello)
(defn ^:export greet [n]
(print(strHellon)))
World)
要编译:
cljsc src'{:optimizations:advanced}'> app-prod.js
然后,使用Rhino运行:
java -jar js.jar app-prod.js
输出:Hello World
希望有帮助!
I understand ClojureScript can be executed within a JavaScript REPL or it can be compiled into JavaScript, then run in a browser. I couldn't find a way to use it on the server side with Rhino. Here is my way of thinking, I have a simple source file:
(ns simple.hello)
(println "Hello, world")
I compile it to hello.js
. I try to run
java -jar js.jar out/goog/base.js out/goog/deps.js out/hello.js
Nothing happens. How can I make it work, or is only Node.js supported on the command line?
This works for me:
src/app.js:
(ns simple.app)
(ns hello)
(defn ^:export greet [n]
(print (str "Hello " n)))
(greet "World")
To compile:
cljsc src '{:optimizations :advanced}' > app-prod.js
Then, to run with Rhino:
java -jar js.jar app-prod.js
Output: Hello World
Hope that helps!
这篇关于使用Rhino从命令行执行编译的ClojureScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!