Fork me on GitHub
#clojurescript
<
2018-03-11
>
Wes Hall18:03:17

Any obvious gotchas for the {:figwheel {:on-jsload "some.thing/here" }} config not working? I get the little clojurescript icon flash, so it looks like the new code is being pushed down the wire, but it's not re-rendering the view. I can call the function from a cljs repl and it works with no issue.

joelsanchez18:03:21

make sure it's a function and not the result of calling the function

Drew Verlee18:03:46

I understand there are some changes to running cljs, but I'm not sure what they are. Is this qs reflective of the changes? https://clojurescript.org/guides/quick-start

Drew Verlee18:03:51

Does it still depend on Java? Someone said you don't need to run Java directly but I didn't understand what that meant

dnolen18:03:41

@drewverlee ClojureScript requires Java unless you’re using bootstrapped - i.e. Planck or Lumo (independently installable)

dnolen18:03:25

Planck is self-contained I think now? (\cc @mfikes), Lumo needs Node.js (I guess it’s self contained too)

mfikes18:03:46

They are both self-contained. Installable via brew and other means.

mfikes18:03:13

(Lumo bundles its own Node.js binary, essentially.)

dnolen18:03:29

@drewverlee these options are popular for scripting as they start fast- but most app dev is happening via ClojureScript that runs against JVM

vaz06:03:41

most? are you aware of any modern setups for building full Node web apps that avoid the JVM with Lumo/etc? Are people just using the Lumo build API directly and gluing it together with component and/or other custom scripts?

dnolen08:03:39

@U3HMZGQ3S I haven’t been following Lumo app dev so I can’t say, might want to check #lumo

mfikes18:03:14

@drewverlee You are probably referring to the changes in this draft of Quick Start, where you can see that you no longer type java to run things (unless on Windows, but that will ultimately change too): https://github.com/clojure/clojurescript-site/blob/quick-start-1.10/content/guides/quick-start.adoc

borkdude19:03:30

I’m trying the new 1.10 cljs quickstart and tried to compile this file: https://github.com/lambdaisland/birch/blob/master/src/birch/core.cljs with target node:

clj -m cljs.main --target node --output-to main.js -c hello-world.core
I end up with a file that does nothing when executed. It doesn’t include the -main function. Where can I find what to do in this case on the clojurescript website?

borkdude19:03:00

This is my deps.edn:

{:deps
 {org.clojure/clojurescript {:git/url “”
                             :sha “2f233d633f6dc44823105fd544685fc4da43ac6c”
                             }
  org.clojure/tools.cli {:mvn/version “0.3.5”}}
 }

borkdude19:03:11

(I removed the code that uses the coloring lib)

dnolen19:03:16

clj -m cljs.main -re node -m hello-world.core is probably what you want

dnolen19:03:03

if you want to compile something that just runs you need kick it off yourself in the source

borkdude19:03:15

yeah:

clj -m cljs.main -re node -m hello-world.core "."
WARNING: Use of undeclared Var hello-world.core/-main in file <cljs repl>
...
that worked (don’t know what the warning is about)

dnolen19:03:49

@borkdude cljs.core/*main-cli-fn* is also a thing, if you set that then when you compile -c w/ -t node then whatever you set that dyn var to will be invoked

borkdude19:03:21

yes, that’s what I needed! thanks

borkdude19:03:39

How do I get everything inside with main.js file without any references to the out folder?

mfikes19:03:56

Add a -O simple

borkdude19:03:16

I tried clj -m cljs.main --target node --output-to main.js -c hello-world.core -O simple but that didn’t work for me

mfikes19:03:34

Move the -O to the left...

mfikes19:03:43

It is an init opt IIRC

borkdude19:03:27

that’s better…

mfikes19:03:57

@borkdude If you end up seeing improvements to the draft instructions here, I could incorporate them. One change I'll make is to simply output to main.js without a path. https://github.com/mfikes/clojurescript-site/blob/issue-177/content/news/2018-03-12-clojurescript-command-line.adoc#creating-a-node-app

borkdude19:03:51

looks fine to me. Why post it as a news article, or will it also be included in guides/references?

borkdude19:03:28

With Reagent I’m always looking through several news posts to find the latest API additions and how they work 😉

mfikes19:03:42

Because the news post has a heavy emphasis on all the stuff you can do with cljs.main (whereas Quick Start is trying to just get you going without illustrating all the neat stuff that cljs.main can do)

mfikes19:03:08

There is some repetition, though, granted

mfikes19:03:52

Here are all the planned doc drafts. Feedback on the PRs welcome: https://gist.github.com/mfikes/bdbe214f03abac88ae384adb1ac26490

borkdude19:03:23

News article is great. But it’s also great to not have to dig through news articles to get the full picture is what I meant with my reference to Reagent

borkdude19:03:57

Found a small typo dirctly on hte, not sure if that’s relevant

dpsutton20:03:03

is it possible to use rebel-readline with cljs right now?

dpsutton20:03:34

seems like cljs.main needs to take -m option instead of rebel readline. is there another way to invoke?

tmarble20:03:22

Just trying 1.10.145 with :nodejs in CIDER and it seems I get a "banner" ever time I eval???

cljs.user> :abc
ClojureScript 1.10.145
:abc
cljs.user> (+ 1 2 3)
ClojureScript 1.10.145
6
cljs.user> 

tmarble20:03:11

@mfikes excellent! (I'm only 3 days late to the party :)

borkdude20:03:04

cljs.user=> (hello-world.core/-main “foo” “bar”)
foobar
nil
cljs.user=> (require ’[hello-world.core :refer [-main]])
clojure.lang.ExceptionInfo: Invalid :refer, var hello-world.core/-main does not exist

bhauman21:03:09

@dpsutton no easy integration of rebel-readline and cljs.main yet

bhauman21:03:19

it can be done for certain

bhauman21:03:49

as cljs.main is easy to compose over

bhauman21:03:05

you can do it yourself by making a main that wraps cljs.main with a rebel-readline, its a great exercise

mfikes21:03:02

@bhauman @dpsutton If you do this, it will bridge cljs.main to rebel-readline with the browser REPL being the "inner" one:

clj -Sdeps '{:deps {github-mfikes/cljs-main-rebel-readline {:git/url "" :sha "262b801da65ec5260e295ed9a478084fa67e58cd"}}}' -i @/bridge.clj -m cljs.main -re rebel-readline-cljs

mfikes21:03:36

I'm working on how to pass in the inner REPL via a -ro option, so if you want node it will give you an wrapped Node REPL, for example.

bhauman21:03:17

it would be cleaner for me to just wrap it

mfikes21:03:38

Yeah, in the end you should 🙂

dnolen21:03:48

@mfikes but honestly that’s also not bad, -i / -m are :main-opts

dnolen21:03:58

so you can put that behind a alias and use it anywhere

bhauman21:03:45

but overriding the repl-env is the hard part

mfikes21:03:23

I suspect it could be -re rebel-readline-cljs with -ro {:wrapped-re "node"}, but I haven't put much thought into it.

bhauman21:03:06

this of course looks differently to me because I designed rebel readline so that you can easily wrap it around anything

dnolen21:03:08

@bhauman so rebel readline needs access to repl-env, it can’t just start the REPL?

dnolen21:03:22

that seems odd if true

mfikes21:03:47

It isn't really a REPL, right? It enhances a wrapped REPL env

bhauman21:03:52

rebel-readline has inline eval

bhauman21:03:52

yeah it's not a repl

bhauman21:03:02

it provides example repls

bhauman21:03:15

and in the cljs case its just a toy

bhauman21:03:33

the readline is separate from the repl entirely

bhauman21:03:42

and this is why it needs a connection

dnolen21:03:43

yeah I dunno, if you need to wrap repl-env then it won’t work in other interesting cases - i.e. Clojure/ClojureScript socket REPLs running under one VM via component or whatever

dnolen21:03:26

so I would say in general wrapping repl-env is not a good idea

bhauman21:03:30

it will work in all of these cases

bhauman21:03:00

how it gets its data is abstracted

bhauman21:03:14

the repl-env is only one way of getting it

dnolen21:03:18

ah k, good

dnolen21:03:13

yeah you really want it to compose, otherwise you’ll write your own version of everything

mfikes21:03:51

@dpsutton This will run cljs.main with Node, if you are interested in that variant

clj -Sdeps '{:deps {github-mfikes/cljs-main-rebel-readline {:git/url "" :sha "74ef9e83e5edd0421b468b581e4b03e8c74c497f"}}}' -i @/bridge.clj -m cljs.main -re rebel-readline-cljs

bhauman22:03:38

@mfikes @dpsutton clojure -e "(require 'cljs.repl)(require 'rebel-readline.cljs.repl)(let [cljs-repl cljs.repl/repl*] (alter-var-root #'cljs.repl/repl* (fn [x] (fn [env opts] (with-redefs [cljs.repl/repl* cljs-repl] (rebel-readline.cljs.repl/repl* env opts)))))nil)" -m cljs.main

bhauman22:03:46

with a simple modification it could be a simpler redef

dpsutton22:03:40

thanks @bhauman I'm porting some stuff from cljx to cljc and wanting to see what it looks like to only use clj tools.

dnolen22:03:39

@borkdude make something minimal so someone can repro

dnolen22:03:47

I couldn’t repro some of your earlier things

borkdude22:03:11

@dnolen ah, my bad, I had (ns hello_world.core)