Clojurians
#cljs-dev
<
2018-03-04
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

dnolen00:03:30

bREPL can now properly handle absolute paths (it wasn’t quite complete before)

mfikes00:03:49

@dnolen Shift-Ctrl-Cmd-4, then Space and then click on the window

dnolen00:03:55

@mfikes I fixed up most of your new reports btw

dnolen00:03:02

self-host appears to work now, etc.

mfikes00:03:31

Cool. Eradicate all the bugs :slightly_smiling_face:

mfikes01:03:00

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"]}
  }

dnolen01:03:19

@mfikes I actually am not using local root for :cljs - too slow :slightly_smiling_face:

dnolen01:03:31

I just put in the latest build

dnolen01:03:51

probably a :cljs-dev one for :local/root makes sense

mfikes01:03:01

Oh, so you do a script/build, then you edit your ~/.clojure/deps.edn to match the build number?

dnolen01:03:01

yeah that’s what I’m doing at the moment

mfikes01:03:26

Cool. Glad I asked. Still trying to learn what workflow works best with this new capabiliity.

dnolen01:03:58

hrm … should we just set -d to a temporary directory if a user invokes -r (not the -c case)

dnolen01:03:12

via (File/createTempFile "out" nil)

mfikes01:03:28

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...

mfikes01:03:27

I was also pondering if any other systems use something akin to -d TMP or some symbolic representation of the idea...

dnolen01:03:10

@mfikes :output-dir is just for compilation artifacts anyway - in the -r case you just want to make a REPL

dnolen01:03:16

you don’t really care that we need the file system

mfikes01:03:25

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 :disappointed:

richiardiandrea01:03:24

Agree to have reasonable non-invasive defaults unless you pass explicitly :output-to or it is in -co

mfikes01:03:27

But, yeah, if there are clearly combinations of flags where the out dir is just a "scratch space" that makes sense.

richiardiandrea01:03:01

At this point it could even be a subfolder in .cljs

richiardiandrea01:03:56

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

dnolen01:03:46

master now makes temp dirs for -r only cases w/o -d set

dnolen01:03:11

no affect on -c + -r

dnolen01:03:37

I guess -m could work this way too?

mfikes01:03:02

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.

mfikes01:03:42

Actually, this is pretty close to the way Planck and Lumo work. They don't cache unless you opt into it.

mfikes01:03:19

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?

dnolen01:03:58

yeah, otherwise you don’t really care

dnolen01:03:11

and with global caching, it’s not even going to be that slow

mfikes01:03:39

Maybe the idea of "I care about the output directory" equates to "I'm explicitly passing -d"

dnolen01:03:46

I’ve done this for -m as well

dnolen01:03:25

feedback welcome but I suspect you’ll almost always combine -r with -c if you want to keep working on something

mfikes01:03:38

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.

dnolen01:03:39

-c gives you default local :output-dir which it feeds to -r

dnolen01:03:44

@mfikes yes

mfikes01:03:35

Do you automatically recursively delete the temp dir? Or is this one of the directory types that Java cleans up for you on exit?

mfikes01:03:02

(Thinking of (File/deleteOnExit ...)

dnolen01:03:34

@mfikes oh are /var/folders not managed by the OS?

mfikes01:03:58

They are on macOS, definitely. I think on reboot or after a long time or somesuch.

dnolen01:03:19

yeah, so I’m not worried about it then

mfikes01:03:37

Maybe the Linux and Windows folk would care. Yeah, they can provide patches.

dnolen01:03:49

also this only for user driven behavior via cljs.main

dnolen01:03:58

not general behavior for REPLs

mfikes01:03:28

It's interesting that cljs.main and shared AOT caching, when combined, are more than the sum of their parts. :slightly_smiling_face:

mfikes01:03:48

Surprising outcome :slightly_smiling_face:

dnolen02:03:57

I’m tweaking master so that you can combine -c with -s

dnolen02:03:05

for advanced builds (REPL doesn’t make sense)

dnolen02:03:38

clj -m cljs.main -O advanced -c hello-world.core -s

dnolen02:03:50

clj -m cljs.main -O advanced -c hello-world.core -s localhost:9001

dnolen02:03:39

the default stuff is pretty fancy now :slightly_smiling_face:

mfikes02:03:45

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

dnolen02:03:55

ha :slightly_smiling_face:

dnolen02:03:21

yeah everything in the ClojureScript jar itself get’s cached

dnolen02:03:30

I didn’t really intend that, but of course anything in JAR goes through that path

dnolen02:03:53

pprint for example is a killer

mfikes02:03:56

Haha! This is gonna put Planck and Lumo out of business. :slightly_smiling_face:

dnolen02:03:01

that’s why the REPL is starting so fast now

dnolen02:03:18

@mfikes hah, not quite - but it certainly makes CLJS feel snappy

dnolen02:03:26

which it definitely did not before

mfikes02:03:49

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.

dnolen02:03:26

yes - just sharing problems this is a game-changer

dnolen02:03:44

Jannis Pohlmann’s om.next report was particularly cool example

dnolen02:03:56

or all your reports in JIRA now @mfikes

richiardiandrea03:03:28

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 :smile:

richiardiandrea03:03:35

The cli stuff is great for CI as well, so I will probably also move tests to clj + cljs.main

richiardiandrea03:03:13

Fortunately it is going to be just a small script change.

dnolen04:03:12

@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

dnolen04:03:41

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

dnolen04:03:12

@richiardiandrea hrm actually I see for -Dclojure.server.repl="{...}" you can pass :args for the :accept-fn

dnolen04:03:01

anyways - should ruminate

dnolen04:03:59

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

richiardiandrea04:03:16

@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)}"

dnolen04:03:01

yeah so changing cljs.server.REPL fns to take args

richiardiandrea04:03:42

Yep take an arg that is map-like...or we'll need to convert to vec of strings and back to map

richiardiandrea04:03:39

Doable, but uglier

richiardiandrea04:03:30

Actually probably not duable because we have nested maps in cljsc_opts.edn

dnolen04:03:57

:args looks like it will be EDN

dnolen04:03:06

in Clojure socket REPL already

dnolen04:03:11

not string

richiardiandrea04:03:23

Oh, so I am misinformed then :)

dnolen04:03:17

@richiardiandrea you don’t need to compose with main

dnolen04:03:34

I think this is all you need

dnolen04:03:55

we could add main support later, but this should be good enough to get you going

dnolen04:03:38

first step is to just compose with Clojure stuff :slightly_smiling_face:

richiardiandrea04:03:02

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

dnolen04:03:23

@richiardiandrea you don’t need your accept fn anymore

dnolen04:03:25

that’s what this fixes

dnolen04:03:41

all standard socket REPL accept fns take args now

richiardiandrea04:03:11

Ok cool will dig more, tomorrow for sure

richiardiandrea04:03:33

I have to say I haven't played with the new stuff yet so I might be missing a piece :wink:

dnolen04:03:47

yep this is fixed

dnolen04:03:49

clj -J-Dclojure.server.repl='{:port 5555 :accept cljs.server.browser/repl :args [{:env-opts {:port 9001}}]}'

dnolen04:03:54

then in a different terminal

dnolen04:03:00

nc localhost 5555

dnolen04:03:01

just works

dnolen04:03:23

and it is awesome :slightly_smiling_face:

richiardiandrea04:03:27

Oh ok, so it is a vector of edn...that was my missing piece

dnolen04:03:06

clj -J-Dclojure.server.repl='{:port 5555 :accept cljs.server.browser/prepl :args [{:env-opts {:port 9001}}]}'

dnolen04:03:08

also just works

dnolen04:03:12

note prepl

richiardiandrea04:03:41

Greeeeeat, I will have a lot of fun tomorrow lol

dnolen04:03:55

I would have done this before but I missed :args

dnolen04:03:28

so next release will also be party time for tooling :slightly_smiling_face:

richiardiandrea04:03:14

@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

dnolen04:03:39

@richiardiandrea right but that’s intentional

dnolen04:03:48

there’s other cases where these Java style directives are EDN

richiardiandrea04:03:14

Ok cool then, if it's intentional I will then need to close the Jira :)

mfikes04:03:49

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).

dnolen04:03:46

@mfikes great! will take a look at that tomorrow

richiardiandrea05:03:57

@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)

dnolen05:03:14

they aren’t really compiler opts

dnolen05:03:19

they are repl options

dnolen05:03:43

you can put compiler stuff in there, but it’s a super set

dnolen05:03:50

this is already true in cljs.main btw, it’s really not a cut and dry thing

richiardiandrea05:03:03

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

dnolen05:03:06

and there are some corners - but they aren’t that common

dnolen05:03:25

I don’t really think it’s worth spending too much time on this

richiardiandrea05:03:50

As long as I can pass in the same cljsc_opts.edn in there I am fine :smile:

dnolen05:03:50

the command line stuff is very sugary

dnolen05:03:01

it does not map well to the real stuff

dnolen05:03:18

but that’s ok IMO

richiardiandrea05:03:30

Will try tomorrow and will open jiras in case like last time

richiardiandrea05:03:44

Cool thanks, gotta rest now :smile:

jannis14:03:12

@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).

jannis14:03:30

So now I’m thinking handle-js-modules may be the culprit.

mfikes14:03:18

@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.

mfikes14:03:53

(Not worth over-engineering that one, definitely.)

dnolen14:03:57

yeah, it’s fine, being able to override is nice for some cases - this really mostly affects people working on the compiler anyway

dnolen15:03:33

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

mfikes15:03:59

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.

dnolen15:03:33

1.10.126 is the next Maven artifact, just waiting for it to show up

mfikes15:03:41

@dnolen 1.10.126 showed up for me

dnolen16:03:26

@mfikes yep I’m posting on the various channels

mfikes16:03:37

I see. :slightly_smiling_face:

mfikes16:03:24

Code complete. Defect fixes and documentation polish over the next week. :slightly_smiling_face:

dnolen16:03:14

@mfikes yeah bugs + I’ll try to go more carefully over your site update PRs

mfikes16:03:49

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.

dnolen16:03:27

@mfikes hrm really, that’s -c + -r

dnolen16:03:37

you shouldn’t get temp dir from Quick Start

mfikes16:03:50

Perhaps user error

dnolen16:03:37

true that will happen in normal case - but probably something simple, source maps are relative so it should resolve

dnolen16:03:00

oh but maybe that’s a bug in our source mapping code for REPLs?

dnolen16:03:21

(yeah, this isn’t browser but direct REPL support)

mfikes16:03:38

Ahh, I do get an out directory, but something else is causing those odd paths. Maybe it is the cached core path.

mfikes16:03:49

I dunno. Hrm. I need to head out.

dnolen16:03:24

@mfikes hrm ok, well people kicking Quick Start is a good way to suss out a lot of bugs :wink:

richiardiandrea18:03:52

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

richiardiandrea18:03:28

it is very cool though, it compiles when the accept function is triggered

richiardiandrea19:03:36

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 :smile:

richiardiandrea19:03:39

crap no, still :npm-deps are not read problem in the socket REPL

richiardiandrea19:03:41

but the patch above works, without it is not even going to start

richiardiandrea19:03:44

will open a jira, I now have to switch to inf-clojure stuff :smile:

dnolen19:03:51

@richiardiandrea your patch is not the right approach

dnolen19:03:04

you don’t need to mess with CLI for now, in fact I want to leave it alone

dnolen19:03:22

if you want a socket REPL use cljs.server.FOO

richiardiandrea19:03:39

that just moves the dissoc up one level, not touching cli

dnolen19:03:39

we’ll sort main support some other time

dnolen19:03:53

you don’t need to dissoc main

dnolen19:03:07

rewind and see how the REPLs worked before

dnolen19:03:16

stop thinking about cljs.main stuff, it does too much

richiardiandrea19:03:39

no yeah but even then, if someone has :main key in the :opts it will break

dnolen19:03:47

REPL take REPL options, which is a super set of compiler options

dnolen19:03:57

@richiardiandrea so just don’t pass main

dnolen19:03:00

this is not a real problem

richiardiandrea19:03:19

I see that that's the solution :smile:

dnolen19:03:20

first get whatever you want working - and think about convenience later

richiardiandrea19:03:59

yeah my thing already works if you exclude :main

dnolen19:03:59

dupe your options for now and verify that what you want can work at all

dnolen19:03:17

ok that’s what I want to know

dnolen19:03:22

I would clean 2612 or close it

dnolen19:03:31

and reopen a simpler ticket

richiardiandrea19:03:42

actually no David, :npm-deps does not yet, so there is that maybe to open

dnolen19:03:15

but this note this stuff is way lower priority

dnolen19:03:21

it’ll get sorted later

richiardiandrea19:03:21

well I am trying to help :smile: this is the stuff that for now keeps me from using CLJS jvm from REPL so I am on a personal quest here :slightly_smiling_face: :slightly_smiling_face:

richiardiandrea19:03:38

I would like to see it working of course :smile:

dnolen19:03:37

what I mean it’s not a priority for the coming release

dnolen19:03:49

we can have subsequent smaller releases with socket REPL fixes

richiardiandrea19:03:57

I will open a ticket for :npm-deps try to see what I can do, you define the priorities of course

dnolen19:03:06

release is going to be dominated by that is all I’m saying

dnolen19:03:14

so I will probably ignore these tickets for the time being

dnolen19:03:22

but yes you should open them :slightly_smiling_face:

dnolen19:03:31

we should track, just setting expecations

richiardiandrea19:03:32

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.

dnolen19:03:57

yes we need to be realistic

dnolen19:03:25

just sorting through cljs.main stuff is taking tons of time, and I suspect as feedback comes in it will get tweaked

dnolen19:03:38

but don’t worry

dnolen19:03:46

I have access to the build button :slightly_smiling_face:

dnolen19:03:52

we can release as much as we need to

richiardiandrea19:03:09

that's not even :main stuff, it is socket REPL super cool enhancement lol :smile:

richiardiandrea19:03:02

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

richiardiandrea19:03:10

that is why I am pushing lol

richiardiandrea19:03:18

anyways, opening Jira

richiardiandrea19:03:51

(I would add, learning a ton in the meantime)

richiardiandrea19:03:21

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

dnolen20:03:46

I silenced browser REPL

dnolen20:03:50

things are fast enough now

dnolen20:03:00

all REPLs now look more or less the same

mfikes22:03:02

When running through the tutorial, I find that REPL evaluations often block if the REPL page is in another non-visible tab. I wonder if Safari really throttles down JavaScript execution in that case.

dnolen22:03:04

@mfikes that’s actually true for most browsers, we should probably mention that

mfikes22:03:29

Yeah, otherwise people will thing things are broken