This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-27
Channels
- # aleph (1)
- # beginners (50)
- # boot (1)
- # cider (35)
- # clojure (28)
- # clojure-dev (15)
- # clojure-uk (15)
- # clojurescript (26)
- # data-science (3)
- # datomic (12)
- # instaparse (30)
- # lumo (85)
- # off-topic (4)
- # perun (2)
- # portkey (24)
- # re-frame (13)
- # reagent (16)
- # ring (1)
- # shadow-cljs (77)
- # spacemacs (2)
- # test-check (3)
- # yada (4)
ok, now I got:
(require 'lumo.build.api)
(lumo.build.api/build "src"
{:target :nodejs
:main 'foo.core/main
:output-to "out/main.js"})
(ns foo.core)
(defn main []
(println (+ 1 2 3)))
(set! *main-cli-fn* main)
$ lumo -c src build.cljs && node out/main.js
goog.require could not find: foo.core.main
there’s really no difference in configuration between the Lumo compiler and the CLJS compiler
yeah, it’s just that I have 0 experience with node and I try it again like once a year :wink:
when you deploy a node script to a server, is it common to make a single script out of it and scp it or npm install the libs on the server in the project dir?
I tried shadow-cljs and there the author said it wasn’t common to make a single file for deploys, that’s why I wanted your opinion. Maybe building on the server is the most convenient
I tried planck but I needed an e-mail library. lumo seems to be more suited, because at least you have the plethora of npm libs
but I think people do deploy servers and npm install
inside docker containers or whatever they’re using
lumo uses self-hosted cljs right? how does it evaluate macros defined in .clj? I’m surprised it works
what’s a nice http lib to use with node? I tried cljs-ajax but I get
WARNING: poppea$macros is a single segment namespace at line 1 poppea.clj
No such namespace: cljs.edn, could not locate cljs/edn.cljs, cljs/edn.cljc, or JavaScript source providing “cljs.edn” in file poppea.clj
ok maybe just this: https://gist.github.com/yogthos/d9d2324016f62d151c9843bdac3c0f23#file-gallery-cljs-L11
Just for reference, I was producing a single JS file with the following: https://github.com/paullucas/les-clj/blob/master/scripts/build#L14
But I am not JS Expert at all so there are probably 100 other ways to do that
I’m trying:
yarn global add uglifyjs
yarn global add browserify
yarn -s browserify --node --standalone index $COMPILED_PATH \
| yarn -s uglifyjs --preamble '#!/usr/bin/env node' -o $BUNDLED_PATH
error Command "browserify" not found.
error Command "uglifyjs" not found.
While browserify
is callable from my shell. @richiardiandrea@borkdude you need to add it to your local package json with yarn add uglify
and yarn add browserify
-> https://github.com/paullucas/les-clj/blob/master/package.json#L43-L46
yarn uglify
calls the locally installed version of the package (it is an JS convenience)
oh ok, in your example I saw only global installs, and you said you were not familiar with node
, sorry :wink:
$ cat package.json
{
"dependencies": {
"moment": "^2.22.1",
"nodemailer": "^4.6.5",
"npm": "^6.1.0"
},
"devDependencies": {
"browserify": "^16.2.2",
"uglifyjs": "^2.4.11"
}
}
I am learning slowly as well, I actually like many of the convenient things the JS tooling offer you :smile:
but the resulting js doesn’t execute properly. I get:
TypeError: Cannot use 'in' operator to search for 'WEATHER_API_KEY' in undefined
I’ll try optimizations :simple
yeah, try :simple
, I had some discussion with David about compiling node with :advanced
and he strongly believes it is not worth it
the browserified version works, so single file is working. uglify is only for compression of the size of the file right?
hmm, it seems the browserified script doesn’t receive the *command-line-args*
correctly
ok, it seems that browserify outputs some dialect of JS that uglify didn’t understand, so I tried uglify-es which worked
@richiardiandrea tip:
yarn add uglifyify
echo '#!/usr/bin/env node' > $BUNDLED_PATH
chmod +x $BUNDLED_PATH
yarn -s browserify -g uglifyify --node --standalone index $COMPILED_PATH >> $BUNDLED_PATH
@borkdude probably late to the party, but if you wanna make sure you JS runs faster with :simple
there are some other options that might come in handy
cool, I’ll try them out, after I get the command line args working in the compiled one
ah, after compiling with :simple
, I print *command-line-args*
and process.argv
:
$ node out/main.js -m
*command-line-args* nil
process.argv #js [/usr/local/Cellar/node/10.2.1/bin/node /Users/Borkdude/Dropbox/dev/clojure/balcony/lumo/out/main.js -m]
Deployed to VPS! Documented + scripts here: https://github.com/borkdude/balcony/tree/master/lumo
borkdude awesome! I think I will reference your repo when I will find the time for the wiki entry
The interesting thing is that even without compilation the script should run way faster than the jvm