clojure - How to execute a single clojurescript file as a script? -
in clojure, can use plugin lein-exec
lein
"execute" single clojure file script this:
lein exec foo.clj
naturally curious whether there similar way "run" single clojurescript file on node.js
directly without process of compiling , run .js file(possibly in terminal)?
thanks!
clojurescript needs compiled js if want execute it. know of there no direct invocation method lein cljsbuild since cljs executes in multiple environments (node, rhino, v8, browser, etc) , each specific how run js, can't make choice you.
here couple of quick ways of running cljs script in node (keep in mind compilation take time since java based , startup time bit bad)
the easy way
the easiest way right (for executing script in node):
lein new mies-node hello-world cd hello-world lein cljsbuild once node run.js
there more templates node cljs, mies-node 1 of them.
the hard (but later more immediate way)
if want hard way, install clojurescript compiler , can this:
$ node -e "$(cljsc hello.cljs '{:target :nodejs :optimizations :whitespace}')"
note: cljsc need in path
note: may give problems externs , not. play options pass compiler
Comments
Post a Comment