Fork me on GitHub
#clojurescript
<
2019-07-17
>
oskarkv00:07:14

@its.ramzi If I were you I would write a document with more details, like the purpose, whether or not it's open source, etc

Ramzi00:07:38

What's wrong with this: (for [n control-panel-functions-list][:option "Add Node"])

Ramzi00:07:09

console says is not ISeqable

pinkfrog00:07:57

for those using hiccup, do you use an extra html formatter?

aisamu02:07:07

Yes, but does a minifier to clutter that even more count?

FHE02:07:35

Hi there. Just wondering why when I go to build a project (quick start) it sees code that is COMMENTED OUT.

FHE02:07:09

"WARNING: string-textarea1 at line 157 is being replaced at line 209

FHE02:07:05

.is thrown even if I comment out either or both of the lines!

FHE02:07:59

Answer: In addition to the core.cljs file in the source folder, I also had a older version name core__V3,1[etc].cljs, and for some reason I guess the build was picking up that file instead of the core.cljs file. Strange.

FHE02:07:12

It worked after I moved that older-version file to another folder.

FHE02:07:43

...but why would it ignore core.cljs in favour of a more oddly named file?

cjmurphy03:07:34

@factorhengineering It will just compile all the files. 'Strange' is not something the compiler knows about.

FHE03:07:37

@cjmurphy Compiling all files present makes so much more sense that selecting one and the 'wrong' one at that. Thanks.

FHE03:07:12

I saw no sign of it having used two completely separate and similar files, though. I'm surprised there were no errors or noticeable odd behaviour with two things trying to manipulate the DOM in different ways. I guess I just blinked through the effects of the 1st and saw the effects of the 2nd.

FHE03:07:06

New question: How do I prevent println from printing to the browser console?

FHE03:07:51

I commented out (enable-console-print!), but the println commands littered throughout my code still work and go to the console!

yuhan04:07:01

looking at the source of enable-console-print!, you could probably call (set-print-fn! nil) and (set-print-err-fn! nil) manually

yuhan04:07:42

odd that there isn't a corresponding disable-console-print! builtin though

pinkfrog05:07:42

hi. how do i connect to a shadowcljs repl?

cjmurphy06:07:15

npx shadow-cljs cljs-repl main works for me, where main is a build defined in shadow-cljs.edn

pinkfrog10:07:24

dunno if you are using luminus or not

cjmurphy11:07:27

No, but I think you need to kill whatever is running at 9631, which is most likely left around from last time you started 'it' up.

pinkfrog11:07:19

9631 is occupied by shdow-cljs watch <build-id>

pinkfrog11:07:00

i have to run shadow-cljs watch <build-id> first before cljs-repl <build-id>

pinkfrog11:07:04

that's what confuses me

Justin Duncan13:07:22

are you using emacs with cider?

donavan09:07:40

Hi, I'm hitting an invalid arity error using apply with more than 21 args here: https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L2054 The function I'm applying to is a library function so I don't have control over wether it has attached metadata. Given that I'm a Clojure newbie, after a quick eyeball of that function, doesn't that rest arg need to be a var-arg (`... & rest`) Though I notice that the protocol https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L563 is also done without a var-arg so maybe this is intentional for reasons that I do not understand. Do I need to manually chunk the args in 21 sized pieces in order to use apply?

thheller09:07:11

20 args is the current cap yes

donavan09:07:34

What is the reason for not supporting var-args?

thheller09:07:03

it is supported. just not past 20

thheller09:07:28

its a limitation in the compiler. there are some open issues regarding that.

donavan09:07:40

Right, ok.

thheller09:07:11

its just rather rare that this is an issue so nobody has worked on it

👍 4
talgiat14:07:08

Is there a way to reuse fspec in clojurscript? the only way to spec functions in clojurescript seems to use fdef but that can’t take fspec defined somewhere else as an argument. My goal is to define a function spec in one place and re-use it for all functions that have the same function spec. This can be done in clojure the following way (I believe):

(def n->n-fn-spec (s/fspec :args (s/cat :n number?) :ret number?))

(s/def add5 n->n-fn-spec)
(defn add5 [n] (+ n 5))

(s/def add6 n->n-fn-spec)
(defn add6 [n] (+ n 6))

dnolen14:07:37

@talgiat ClojureScript has fspec can you be more clear about what's not working?

talgiat14:07:45

the example I posted is not working with instrument

talgiat14:07:20

Looking at clojurescript fdef code (https://github.com/clojure/clojurescript/blob/230e46aee2c9b76e426e85865ab8930c4c26e14f/src/main/cljs/cljs/spec/alpha.cljc#L443) it adds the fn-sym to specedvars atom that is used with instrument. This is not the case in the clojure spec code where (I believe) the example I pasted above works with instrument

lepistane16:07:57

hi guys i am having trouble doing advanced compilation for my project I am using https://github.com/cljsjs/packages/tree/master/semantic-ui-react and i am able to compile it with :simple optimization but when i put :advanced i get

TypeError: c.vd is not a function
I feel like i am missing some compiler option in order to make :advanced work. The jar comes with deps.edn that have :foreign-lib description in it i am not sure what to do? How would you approach this? i wouldn't want to use shadow-cljs just yet as i want to understand compiler more and not get stuck in the future on this I am using clj cli, deps and figwheel main template this is my prod.cljs.edn
{:main routes.core
 :output-to "resources/public/cljs-out/dev-main.js"
 :output-dir "resources/public/cljs-out/out"
 :asset-path "cljs-out/out"
 :optimizations :advanced
 :closure-defines {goog.DEBUG false}
 :pretty-print false
 :infer-externs true
 :closure-warnings
 {:externs-validation :off :non-standard-jsdoc :off}
 :externs ["react/externs/react.js"]}

valtteri16:07:06

Probably externs cannot be inferred for all the calls you're making from your code to foreign-libs. Try adding this on top of one of the namespaces where you're doing interop and see if you get any warnings (set! *warn-on-infer* true)

valtteri17:07:24

You can also set :pseudo-names compiler option to true to see more clearly which part of your code is failing with advanced optimizations

lepistane17:07:23

omg it helped

lepistane17:07:47

thank you @valtteri you are the best

lepistane17:07:43

turns out i was not interopping properly. fixed that and it worked

valtteri17:07:53

Cool! I'm glad you found the issue.

pcljlearn18:07:07

totally new to cljs, I am following a tutorial <https://clojurescript.org/guides/quick-start>, running the command in a remove server w/o X11, after I compiled by running

clj --main cljs.main --compile hello-world.core --repl

I was able to load the page with GUI browser locally using the IP address. In the console, it also said there was an option to turn off launching browser by passing REPL option :launch-browser false, but where and how shall I config this option?

pcljlearn18:07:06

I without passing the :launch-browser false option, I am not able to get to the REPL or see the Hello World output. Please help

dnolen18:07:10

you can pass that option with -ro

dnolen18:07:27

clj --main cljs.main --help for more info

dnolen18:07:52

@talgiat did you actually confirm that works in the Clojure?

dnolen18:07:21

I thought fdef was needed for instrument to work

Alex Miller (Clojure team)18:07:29

in the clojure impl (not sure about cljs) s/fdef is just an s/def where the key in the registry is a symbol, instead of a keyword

pcljlearn18:07:52

@dnolen thanks! But I tried the following

clj --main cljs.main --compile hello-world.core --repl -ro {:launch-browser false}
it did not work. I tried to find out what "edn string" was (as suggested by the --help output).

dnolen18:07:10

@prodt90 the help string is pretty clear about the arg order

dnolen18:07:12

-ro can't come last

dnolen18:07:28

I would read through it at least once

dnolen18:07:27

@talgiat post your minimal failure into a ticket - should be a relatively easy fix

dnolen18:07:35

@alexmiller thanks that's helpful

dnolen18:07:09

@prodt90 also that edn string must be in double quotes

dnolen18:07:14

are you on Ubuntu?

pcljlearn19:07:26

Yes, it is on Ubuntu.

pcljlearn19:07:57

Here is what I tried: none of them worked. clj --main cljs.main -ro ":launch-browser false" --compile hello-world.core --repl clj --main cljs.main -ro {:launch-browser "false"} --compile hello-world.core --repl clj --main cljs.main -ro {":launch-browser false"} --compile hello-world.core --repl

pcljlearn19:07:14

clj --main cljs.main -ro {:launch-browser false} --compile hello-world.core --repl Execution error at cljs.cli/repl-env-opts-opt (cli.clj:229). EOF while reading Full report at:

dpsutton19:07:16

clj --main cljs.main -ro "{:launch-browser false}" --repl worked for me

pcljlearn19:07:41

Oh yeah, this time it did not give me error, also the page loaded but on the remote server where the command was runnng, it did not return me a REPL. also there was no "hello world" printed out.

pcljlearn19:07:23

This is what I ran on the Ubuntu server: clj --main cljs.main -ro "{:launch-browser false}" --compile hello-world.core --repl it has been just hanging on the terminal "Waiting for browser to connect to http://localhost:9000 ..."

pcljlearn19:07:05

I even tried using text terminal on remote server to connect to localhost:9000, which loads the HTML successfully, but still no REPL for me.

dnolen19:07:55

@prodt90 we don't test with a remote server so who knows what issues are involved here - did you try locally?

pcljlearn19:07:21

ok. let me try

nwjsmith20:07:19

Anyone here using Tsickle (https://github.com/angular/tsickle) to get better Closure advanced compilation for JS dependencies?

pcljlearn20:07:19

@dnolen I tried to use a server to run the command clj --main cljs.main -ro "{:launch-browser false}" --compile hello-world.core --repl It did not return Hello World, unless I open a GUI browser on the same machine, Waiting for browser to connect to http://localhost:9000 ... Hello World! ClojureScript 1.10.516 cljs.user=> (+ 3 5)

pcljlearn20:07:52

I.e., a text browser failed to trigger opening the REPL, . Those seemed to me at lease two bugs involved.

pcljlearn20:07:24

I am simply trying to follow the simpliest tutorial in the world to learn cljs tihs afternoon.

dpsutton20:07:24

what do you mean by text browser?

dpsutton20:07:41

that most probably doesn't execute js so no chance of it working

pcljlearn20:07:50

ok. I see. But is there a way to go directly to the repl once compiled?

chepprey20:07:58

To keep things simple, probably best to use the most normal setup that cljs was intended for. That wouldn't be remote servers and text browsers. It'd be Chrome or FF on a normal PC with a GUI.

pcljlearn20:07:23

I expect the command I run would say hello world and give me a repl, if I use :launch-brower false.

chepprey20:07:25

Clojurescript needs a javascript VM in order to run and do anything. Commonly that JSVM is in a (normal modern) browser. I think it can also be done via Node.js. But you might need to follow instructions or a tutorial that's meant specifically for that.

dnolen20:07:57

@prodt90 if you don't want a browser use the Node repl w/ -re node

dnolen20:07:47

otherwise go w/ the flow use Chrome and do it locally

dnolen20:07:00

for the Node REPL to work you must have Node.js installed first

pcljlearn20:07:34

ok. thanks for the tips, yeah, that is very helpful. the problem I met is actually no big deal, I need to keep things simple like you said.

chancerussell21:07:57

Anyone know if it’s possible to get a handle to the com.google.javascript.jscomp.CompilerOptions object at compile-time?