Fork me on GitHub
#clojurescript
<
2018-01-22
>
rauh06:01:16

@alexisvincent Personally I use one project.clj file and profiles.

alexisvincent07:01:13

Thanks :) I just had an issue with the cljs repl loading a dep that was only meant for server side

alexisvincent07:01:29

@rauh is it possible to specify different profiles for cljs and clj repl

alexisvincent07:01:52

@rauh is it possible to specify different profiles for cljs and clj repl

rauh07:01:02

The default profile will add all deps in :dependencies so Cursive will see them all. But you never run just with lein .... You always specify lein with-profile clj-dev or cljs-prod etc.

alexisvincent07:01:11

Thanks that’s helpful. In the past I’ve used cider-jack-in, guess if I want to specify profiles I’m going to have to start from the terminal right?

rauh07:01:29

I always start the REPL from the command line, yes. IMO it should be the canonical way and then just connect to it from your editor. Then you have a figwheel (CLJ) repl and can upgrade it to a CLJS repl with one command.

alexisvincent08:01:39

@rauh Starting repl from cli feels correct, but do you have any other reasons you think it should be the canonical way?

rauh08:01:34

@alexisvincent Because: 1. You have by default always access to the CLJ side of the figwheel/clj-compiler REPL. Which mean you can debug macros more easily. 2. Just restarting the CLJS compiler will not require you to restart the entire REPL every time. You just quit the CLJS repl and start figwheel again. 3. On an error you don't have to restart the REPL. 4. There wouldn't be countless confusion on how to start a CLJS Repl in the various editors. You just start your NREPL first and connect to that. Then, you start your CLJS Repl on top of it with a (hand typed) simple command (in my config (load-file "scripts/fw.clj"). There is no magic, and people would actually understand what's happening. Heck you could even start different CLJS builds from within the same JVM to save on memory.

alexisvincent08:01:13

Makes sense. I’ll play with this on Friday, have a deadline for Wednesday. Been wanting to move that way for a bit. In a separate question, whenever I add [org.docx4j/docx4j “3.3.6”] (sad, I know) as a lein dep and start a figwheel repl, it dies with nonsense like this

Exception in thread "main" java.lang.ExceptionInInitializerError
	at clojure.main.<clinit>(main.java:20)
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V, compiling:(closure.clj:100:1)
clj repl is fine. Leads me to think figwheel is trying to load docx4j but failing because it needs the jvm

rauh08:01:26

@alexisvincent Just a dependency clash. your docx pulls in guava v19 and google Closure compiler uses something newer. Specify the guava version manually (at your own risk)

rauh08:01:53

Do a lein deps :tree to see what is actually being used

rauh08:01:14

But yeah, the correct approach is to not pull in docx4j when compiling CLJS

rauh08:01:02

That's the main reason I'm doing this:

alexisvincent08:01:30

@rauh Super useful 🙂 Thanks man 🙂

sggdfgf11:01:18

can I mix get function vs aget everywhere? I can not find a difference...

mfikes12:01:30

@faxa aget's intended use is on JavaScript arrays, FWIW

Jakub Holý (HolyJak)14:01:09

Hello! I want to 1) use a library from node_modules, 2) don't want its code to be included in the resulting source bundle (since it is pre-installed in my target execution environment), 3) and need to make sure that :advanced optimizations won't change the names of the library's functions when I call them from my code. Is there any other way than providing an externs file myself? Currently I js/require the library and do not add it to :foreign-libs or :npm-modules to solve 1 and 2 but I struggle with GCC renaming the functions => at runtime it fails I guess I will need to either write an externs file or extract the one from cljsjs/aws-sdk-js (I tried to just add cljsjs/aws-sdk-js but that did not make GCC understand it should use the externs file from it with the manually js/require-d library. I am not even sure that providing externs manually will help here :()

souenzzo14:01:16

You will need "externs" to allow advanced without renaming.

Jakub Holý (HolyJak)14:01:57

Oh, I forgot about that one. You are right, that is perhaps my best option.

wontheone114:01:28

have anyone used cljs-pdfkit? I cannot get the namespace resolved 😞

rauh14:01:41

@holyjak You might not need advanced for server side (node) code, I think you can get 95% of the performance of advanced with :simple (which will only rename local variables). Just make sure :static-fns is on which is major performance win

Jakub Holý (HolyJak)14:01:50

in general you are right but I` am writing an AWS Lambda function so small size matters

rauh14:01:14

Then I'd probably just do js/... interop and use infer externs to automatically get those externs

Jakub Holý (HolyJak)14:01:49

I do js/require the library but infer externs does not help, it does not mention the library (`AWS`) at all 😞

Jakub Holý (HolyJak)14:01:51

(def AWS (nodejs/require "aws-sdk"))
(def sts (AWS.STS. #js {"apiVersion" "2011-06-15"})) ; this works
`(.assumeRole sts ...)` ; this fails: "TypeError: as.Xd is not a function"

rauh15:01:39

You'd have to write (js/AWS.STS. ...) and (.assumeRole ^js/The.AWS.TYPE sts ...)

rauh15:01:12

(Untested)

Jakub Holý (HolyJak)16:01:05

I discovered why assumeRole of AWS.STS did not work - because it is not included in the cljsjs/aws-sdk-js externs. The library does magic I dont understand so that you can call the funtion but it is newer explicitely defined as far as I can see and thus is not in the externs.

Jakub Holý (HolyJak)16:01:20

And I don't need js/. When I switch to .assumeRoleWithSAML which is in the externs then the code works as is

Jakub Holý (HolyJak)19:01:16

@U2J4FRT2T setting :pseudo-names true increased the size from 350kB to 1.4MB. Also, it doesn't preserve names, it still uses generated by readable names (here $assumeRole$)

souenzzo19:01:46

I had never used it, I was planning, but I already saw that it will not work

oibot18:01:37

How do I use geolocation in react-native with re-natal (+re-frame) in clojurescript. More specific, how do I get hold of the global variable navigator that enables me to make my geolocation requests.

Jakub Holý (HolyJak)19:01:06

Where do I place externs? On the classpath, i.e. typically in a resources/mylib.js ?

dnolen19:01:43

@holyjak I’m pretty sure we also check file location location relative to Java process dir

Jakub Holý (HolyJak)19:01:26

Thanks! I think it would be really good to add this info to https://clojurescript.org/reference/compiler-options#externs

juhoteperi19:01:55

Maybe it would be good to specify that :compiler-options :externs are first searched from working directory, and then if not found, from classpath. deps.cljs :externs are only loaded from classpath.

juhoteperi19:01:30

Or well, that page is about compiler options so it's probably good. Foreign deps have their own page.

dnolen19:01:49

but classpath works too

mfikes19:01:56

@oibot There is a #cljsrn channel with users into RN

mfikes19:01:57

@oibot In general, js/ provides a gateway to the global JavaScript scope