Closed abhi18av closed 6 years ago
I've tweaked the cljsbuild
section to include the following
{:id "nodejs"
:source-paths ["src/cljs" "src/cljc" "dev"]
:compiler {:main cljs.user
:target :nodejs
:asset-path "js/compiled/out"
:output-to "resources/public/js/compiled/nodejs/nodejs.js"
:output-dir "resources/public/js/compiled/nodejs"
:source-map-timestamp true}}
I've started to work on a seperate branch with chestnut/master
as base here https://github.com/abhi18av/devnagri-ui-tests/tree/node-repl
I've made progress with the configuration here
{:id "nodejs"
:source-paths ["src/nodejs" "src/cljc" ]
:compiler {:main cljs.user
:target :nodejs
;:asset-path "js/compiled/out"
:output-to "resources/public/js/compiled/nodejs/nodejs.js"
:output-dir "resources/public/js/compiled/nodejs"
:pretty-print true
:optimizations :simple
;:optimizations :advanced :simple :whitespace :none
:parallel-build true
:npm-deps {"chalk" "2.1.0"}
:install-deps true
;:source-map-timestamp true
;:source-map true
:warnings false}}
And the code in src/nodejs/devnagri_ui_tests/nodejs.cljs
is as follows
(ns devnagri-ui-tests.nodejs
(:require [clojure.string :as str]
[cljs.nodejs :as nodejs]))
(nodejs/enable-util-print!)
(defn -main [& args]
(-> (str/join " " args)
(str/replace #"cker\b" "xor")
(str/replace #"e|E" "3")
(str/replace #"i|I" "1")
(str/replace #"o|O" "0")
(str/replace #"s|S" "5")
(str/replace #"a|A" "4")
(str/replace #"t|T" "7")
(str/replace #"b|B" "6")
(str/replace #"c|C" "(")
println))
(set! *main-cli-fn* -main)
But running the node
on the output
doesn't print out anything at all
❯ npm test
> devnagri-ui-tests@1.0.0 test /Users/eklavya/Projects/ProjectEklavya/BlueCollar/devnagri-ui-tests
> /Users/eklavya/.nvm/versions/node/v8.1.3/bin/node resources/public/js/compiled/nodejs/nodejs.js
The expected output is as follows
$ l33t I am a leet hacker
1 4m 4 l337 h4x0r
This is taken from blog-post by plexus here https://lambdaisland.com/blog/02-05-2017-nodejs-scripts-clojurescript
Hey there!
The one issue I was running into with your code specifically was that your version of clojurescript didn't seem to like compiling node. The following worked:
[org.clojure/clojurescript "1.9.946" :scope "provided"]
.
Your cljs main should probably also be devnagri-ui-tests.nodejs
:
{:id "nodejs"
:source-paths ["src/nodejs" "src/cljc" ]
:compiler {:main devnagri-ui-tests.nodejs
:target :nodejs
;:asset-path "js/compiled/out"
:output-to "resources/public/js/compiled/nodejs/nodejs.js"
:output-dir "resources/public/js/compiled/nodejs"
:pretty-print true
:optimizations :simple
;:optimizations :advanced :simple :whitespace :none
:parallel-build true
:npm-deps {"chalk" "2.1.0"}
:install-deps true
;:source-map-timestamp true
;:source-map true
:warnings false}}
In the future, this kind of thing would be ideal to bring up in the mailing list or on the clojurian slack, not as an issue here.
Hi guys,
I've been trying to get
chestnut
working with anodejs-repl
instead of abrowser-repl
but I'm lost in the configurations ofcljsbuild
. Could you help me achieve this ?