Fork me on GitHub

@lockdown- you mean in terms of interop? no you just use the this-as macro

👍 4

is there a uuid generator in cljs?


built in one I mean


@bravilogy yes. random-uuid and uuid


hmm doesn’t seem to work 😕


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


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


it should be :advanced

👍 4

but no idea if that is the actual problem


@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


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.


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

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

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


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


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


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


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.


I think that's the best option then


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


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


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


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


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


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


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.


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