This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-04
Channels
- # beginners (149)
- # cider (1)
- # clara (12)
- # cljs-dev (226)
- # cljsrn (2)
- # clojure (275)
- # clojure-russia (5)
- # clojure-uk (14)
- # clojurescript (57)
- # cursive (23)
- # data-science (15)
- # datomic (1)
- # fulcro (8)
- # hoplon (9)
- # onyx (5)
- # portkey (15)
- # protorepl (1)
- # re-frame (8)
- # reagent (17)
- # shadow-cljs (22)
- # uncomplicate (13)
- # vim (36)
I'm curious what clj
aliases people have found useful for CloureScript dev. I've been using a :local/root
one that also adds the main opts, which it looks like David must be doing with -A:cljs
:aliases {
:cljs-dev {:extra-deps {org.clojure/clojurescript {:local/root "/Users/mfikes/Projects/clojurescript"}}
:main-opts ["-m" "cljs.main"]}
}
Oh, so you do a script/build
, then you edit your ~/.clojure/deps.edn
to match the build number?
Cool. Glad I asked. Still trying to learn what workflow works best with this new capabiliity.
hrm … should we just set -d
to a temporary directory if a user invokes -r
(not the -c
case)
Yeah, I was trying to think what conditions that might make sense. The only thing I could think of is if any directories in the classpath (usually only "src"
) doesn't exist on the filesystem...
I was also pondering if any other systems use something akin to -d TMP
or some symbolic representation of the idea...
@mfikes :output-dir
is just for compilation artifacts anyway - in the -r
case you just want to make a REPL
I didn't know about that createTempFile
API. It looks like it doesn't make a directory. I used
(defn- ^File make-temp-dir []
(.toFile (Files/createTempDirectory "cljs-cli-test" (make-array FileAttribute 0))))
in CLJS-2593, which is much more complex 😞Agree to have reasonable non-invasive defaults unless you pass explicitly :output-to
or it is in -co
But, yeah, if there are clearly combinations of flags where the out dir is just a "scratch space" that makes sense.
At this point it could even be a subfolder in .cljs
On an unrelated note, today I have open a CLJ Jira having the end goal of passing an option map to the cljs socket repls: https://dev.clojure.org/jira/browse/CLJ-2331
Only thought I have on that is that if you are, say, running unit tests using -m
to start your test runner, then maybe making a temp directory would cause everything to be rebuilt? But, perhaps that is OK, because if you want it to be fast you opt into explicitly setting -d
.
Actually, this is pretty close to the way Planck and Lumo work. They don't cache unless you opt into it.
Backing up, maybe the question is: When do you really care about the output directory? - When you are compiling something and you actually care about the artifacts. - When you are running something "again" and you want it to be faster?
Maybe the idea of "I care about the output directory" equates to "I'm explicitly passing -d"
feedback welcome but I suspect you’ll almost always combine -r
with -c
if you want to keep working on something
Cool. This might work out to make things simpler for a lot of use cases. No dirtying the filesystem unnecessarily or adding the complexity of end-users worrying about it.
Do you automatically recursively delete the temp dir? Or is this one of the directory types that Java cleans up for you on exit?
It's interesting that cljs.main
and shared AOT caching, when combined, are more than the sum of their parts. 🙂
Awesome, I can't measure a difference in
time clj -A:cljs -d out -re node -e 3
vs
time clj -A:cljs -re node -e 3
Well, truthfully, Planck and Lumo are fast to start up, but oftentimes I wan't to check behavior for non-self-hosted ClojureScript. And this is much faster to start up a REPL and more easy than before.
My current workflow is lumo REPL + JVM compilation. The biggest winner (I would consider switching to Cljs non-self-host!) for node is the socket Repl. Prepl is the way to go for tooling. I am putting together some work on inf-clojure
for improving things and hopefully at some point we'll have a socket prepl that runs the same as the terminal one. It is just a matter of coming up with the correct accept function I know 😄
The cli stuff is great for CI as well, so I will probably also move tests to clj + cljs.main
Fortunately it is going to be just a small script change.
@richiardiandrea good to hear, yeah after the release I want to loop back and see if we can make the REPL/pREPL + socket repl smoother - the Clojure API is a bit limiting
cljs.main
can probably just support it directly and we have enough flags to give you control w/o writing a lot of custom code
@richiardiandrea hrm actually I see for -Dclojure.server.repl="{...}"
you can pass :args
for the :accept-fn
above I’m implying you really shouldn’t try to use cljs.main
instead just invoke the REPL you want with the options you want via :args
@dnolen yep you can and the Jira is exactly about that: now args accepts a vector of strings...if we could pass a map (or edn, more generically), we are good to do -D....="{:accept .... :edn-args $(cat cljsc_opts.edn)}"
Yep take an arg that is map-like...or we'll need to convert to vec of strings and back to map
Sorry on mobile
Doable, but uglier
Actually probably not duable because we have nested maps in cljsc_opts.edn
Oh, so I am misinformed then :)
I saw this guy here: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/server.clj#L90
Sorry wait
Line 90
And https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/server.clj#L77
@richiardiandrea https://github.com/clojure/clojurescript/commit/265f398c2eec62aef2c7daff108c89da865ac562
@richiardiandrea you don’t need to compose with main
Thanks awesome, yep that was necessary too. Will try things out, probably that jira is still good as improvement but I can close over my own accept fn with you last patch
@richiardiandrea you don’t need your accept fn anymore
Ok cool will dig more, tomorrow for sure
I have to say I haven't played with the new stuff yet so I might be missing a piece 😉
clj -J-Dclojure.server.repl='{:port 5555 :accept cljs.server.browser/repl :args [{:env-opts {:port 9001}}]}'
Oh ok, so it is a vector of edn...that was my missing piece
It is!!!
clj -J-Dclojure.server.repl='{:port 5555 :accept cljs.server.browser/prepl :args [{:env-opts {:port 9001}}]}'
Greeeeeat, I will have a lot of fun tomorrow lol
Definitely
@dnolen for completeness, I found out where the read-string
is done. A bit hidden, but that is why it works. Probably a lucky side effect. The jvm properties are read with read-string
;)
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/server.clj#L153
@richiardiandrea right but that’s intentional
Ok cool then, if it's intentional I will then need to close the Jira :)
Good news: https://dev.clojure.org/jira/browse/CLJS-2607 implies that we might not yet be fully utilizing the shared AOT cache (and that things will run even faster in the end for cold runs).
@dnolen only a possible improvement on naming on that one. Should we have :compiler-opts
instead so that everything is coherent? (Main opts are using that term)
Ah yeah I think I read it somewhere, it is just probably worth exposing a coherent interface and the merge internally like in cljs.main
, I can put a patch together
As long as I can pass in the same cljsc_opts.edn
in there I am fine 😄
Will try tomorrow and will open jiras in case like last time
Cool thanks, gotta rest now 😄
@anmonteiro I think you’re half-right about add-js-sources
being were .mjs
modules fail to be added. Specifically, add-js-sources -> js-dependencies
fails adding all .mjs
dependencies of the top-level .mjs
module (in this case, module$Users$jannis$Work$oss$clojure$clojurescript$node-modules$graphql$index-mjs
). It tries them in the loop in js-dependencies
but the following always returns nil
for them:
(or (get (@env/*compiler* :js-dependency-index) (first requires))
(deps/find-classpath-lib (first requires)))
In all these cases, it fails to find the items in requires
in the :js-dependency-index
and tries find-classpath-lib
instead, which I guess is wrong?
My interpretation is that things already go wrong earlier: all those .mjs
deps (in this case, (module$Users$jannis$Work$oss$clojure$clojurescript$node-modules$graphql$graphql module$Users$jannis$Work$oss$clojure$clojurescript$node-modules$graphql$execution module$Users$jannis$Work$oss$clojure$clojurescript$node-modules$graphql$subscription module$Users$jannis$Work$oss$clojure$clojurescript$node-modules$graphql$error)
) should be included in :js-dependency-index
but are not. That’s what I’ll check next (if you think that makes sense).@dnolen Sorry about the race between you and me on CLJS-2606. FWIW, I think the patch you applied is probably the one I would have went with in the end.
yeah, it’s fine, being able to override is nice for some cases - this really mostly affects people working on the compiler anyway
getting to point where I think feedback on this before release would be good https://github.com/clojure/clojurescript-site/blob/1a288e33ba58a3d87e8192caafc75458f53f70e7/content/guides/quick-start.adoc, going to cut a release, update this and ask people to try it out
Yeah, I think that is a good idea. Seems like there are no critical bugs and broader beta testing at this point would be valuable.
For me (Safari), the (ffirst [1])
first impression will be off-putting, given the synthetic directory structure.
cljs.user=> (ffirst [1])
Error: 1 is not ISeqable
(/private/var/folders/gx/nymj3l7x4zq3gxb97v2zwzb40000gn/T/out667248762303295388152139830015529/out/cljs/core.js:4441:17)
(/private/var/folders/gx/nymj3l7x4zq3gxb97v2zwzb40000gn/T/out667248762303295388152139830015529/out/cljs/core.js:4460:22)
(/private/var/folders/gx/nymj3l7x4zq3gxb97v2zwzb40000gn/T/out667248762303295388152139830015529/out/cljs/core.js:5904:23)
I'll capture this as a JIRA enchancement to ponder.true that will happen in normal case - but probably something simple, source maps are relative so it should resolve
Ahh, I do get an out
directory, but something else is causing those odd paths. Maybe it is the cached core path.
@mfikes hrm ok, well people kicking Quick Start is a good way to suss out a lot of bugs 😉
tried the yesterday's cool introduction of the socket REPL yesterday...it work, but suffers of the same bug with :main
https://dev.clojure.org/jira/browse/CLJS-2612
it is very cool though, it compiles when the accept function is triggered
I attached a patch to https://dev.clojure.org/jira/browse/CLJS-2612, if you folks have some time to try a couple of combinations with -c
, I am making sure the REPLs are fixed. I think this seals it @dnolen 😄
crap no, still :npm-deps
are not read problem in the socket REPL
but the patch above works, without it is not even going to start
will open a jira, I now have to switch to inf-clojure
stuff 😄
@richiardiandrea your patch is not the right approach
that just moves the dissoc
up one level, not touching cli
no yeah but even then, if someone has :main
key in the :opts
it will break
@richiardiandrea so just don’t pass main
I see that that's the solution 😄
yeah my thing already works if you exclude :main
actually no David, :npm-deps
does not yet, so there is that maybe to open
ok cool
well I am trying to help 😄 this is the stuff that for now keeps me from using CLJS jvm from REPL so I am on a personal quest here 🙂 🙂
I would like to see it working of course 😄
I will open a ticket for :npm-deps
try to see what I can do, you define the priorities of course
kk sounds good
if I can express my opinion, that's a pity though, because this is great stuff for tooling...but I see your point as well. Priorities need to be set.
just sorting through cljs.main
stuff is taking tons of time, and I suspect as feedback comes in it will get tweaked
that's not even :main
stuff, it is socket REPL super cool enhancement lol 😄
yep not worried
cider
and inf-clojure
are not doing crazy tricks for starting CLJS REPLs and this is actually the first time I see a smooth path to it
that is why I am pushing lol
anyways, opening Jira
(I would add, learning a ton in the meantime)
ok opened https://dev.clojure.org/jira/browse/CLJS-2613. The comand I am using is really cool so thanks for that:
clojure -J-Dclojure.server.repl="{:port 5555 :accept cljs.server.node/repl :args [{:opts $(cat cljsc_opts.edn)}]}" -Srepro