Fork me on GitHub
#clojurescript
<
2018-05-25
>
justinlee00:05:30

@lockdown- you mean in terms of interop? no you just use the this-as macro https://cljs.github.io/api/cljs.core/this-as

👍 4
Bravi00:05:34

is there a uuid generator in cljs?

Bravi00:05:58

built in one I mean

justinlee00:05:00

@bravilogy yes. random-uuid and uuid

Bravi00:05:15

hmm doesn’t seem to work 😕

mfikes03:05:45

There is also a uuid generator for use with generative testing, so you can, for example (s/exercise uuid?)

grahamcarlyle07:05:17

Am i passing the --compile-opts correctly? clj -m cljs.main --output-to main.js --compile-opts "{:optimizations advanced :infer-externs true}" --compile hello-expo.core With version 1.10.238 i get a stacktrace,

Exception in thread "main" java.lang.Exception: Could not write JavaScript nil
at cljs.closure$write_js_QMARK_.invokeStatic(closure.clj:1892)
Its ok without that parameter

rakyi07:05:20

it should be :advanced

👍 4
rakyi07:05:38

but no idea if that is the actual problem

Bravi08:05:51

@lee.justin.m ah I was trying to evaluate it within cider and it looks like cider doesn’t know what random-uuid is. but it works in the actual app / browser

grahamcarlyle08:05:34

thanks, so i typo'd the advanced, it should have been the keyword :advanced. I'm wondering if there is a process people use to resolve problems like this that result in a stacktrace. Do they crank up a debugger and step through to see where things went wrong? I don't think I could have worked out what was wrong just looking at the stacktrace.

grahamcarlyle08:05:29

For example I translate the command line I got wrong initially above to a deps.edn alias and I now get another stacktrace

{:deps
 {org.clojure/clojurescript {:mvn/version "1.10.238"}}

 :aliases
 {:prod-build {:main-opts ["-m" "cljs.main"
                           "--output-to" "main.js"
                           "--compile-opts" "{:optimizations :advanced, :infer-externs true}"
                           "--compile" "hello-expo.core"]}}}

grahamcarlyle08:05:52

Exception in thread "main" java.lang.RuntimeException: EOF while reading
	at clojure.lang.Util.runtimeException(Util.java:221)
...

grahamcarlyle08:05:12

this time the full stack trace suggests its the edn for compile-opts. Weirdly if I replace the spaces in compile-opts with commas (which i believe are treated as whitespace) then it works again, which suggests the edn parser is being passed a string split on spaces? "--compile-opts" "{:optimizations,:advanced,,:infer-externs,true}"

pesterhazy09:05:29

isn't there a way to supply the compile opts as data instead of a string?

grahamcarlyle09:05:58

i think you can specify a file which contains the EDN

-co, --compile-opts edn     Options to configure the build, can be an EDN 
                              string or system-dependent path-separated list of 
                              EDN files / classpath resources. Options will be 
                              merged left to right.

pesterhazy09:05:28

I think that's the best option then

pesterhazy09:05:55

It might be worth checking if there's a JIRA for the issue with compile-opts containing spaces

pesterhazy09:05:11

Sounds like something somewhere is trying to parse that string as shell arguments

grahamcarlyle09:05:05

I couldn't find an issue in JIRA that matched this but that may be more due to my unfamiliarity with JIRA

pesterhazy09:05:45

@grahamcarlyle if you can reduce it to a minimal repro, consider filing a ticket

pesterhazy14:05:09

@grahamcarlyle can repro. Curiously it works from the cli clj -m cljs.main --compile-opts "{:foo :bar}" --compile hello-world.core

bhauman15:05:39

the compiler and cljs.main both should validate at least some of the config values

grahamcarlyle15:05:05

i'm interested to know how people go about understanding issues when the cljs tools fail with a stacktrace. Ideally the tool would fail more gracefully or helpfully. I'm a cljs newbie and i've been baffled a number of times with such failures. I could imagine using a debugger to work back from the stacktrace to try to gain some insight and so maybe thats would i should get more practiced at.

pesterhazy16:05:53

@grahamcarlyle thanks for filing the issue, this will help the next person find the issue in tools.deps