This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-22
Channels
- # architecture (30)
- # beginners (56)
- # cider (16)
- # cljs-dev (12)
- # cljsrn (21)
- # clojure (169)
- # clojure-austin (1)
- # clojure-estonia (1)
- # clojure-italy (3)
- # clojure-russia (1)
- # clojure-spec (56)
- # clojure-uk (46)
- # clojurescript (53)
- # consulting (3)
- # core-async (3)
- # cursive (14)
- # data-science (16)
- # datascript (1)
- # datomic (26)
- # defnpodcast (11)
- # docs (3)
- # emacs (6)
- # fulcro (4)
- # graphql (24)
- # hoplon (8)
- # instaparse (4)
- # java (2)
- # jobs (1)
- # jobs-rus (1)
- # jobs_rus (1)
- # keechma (1)
- # luminus (2)
- # lumo (1)
- # mount (36)
- # off-topic (30)
- # om-next (5)
- # onyx (29)
- # precept (23)
- # re-frame (20)
- # reagent (2)
- # remote-jobs (9)
- # ring (2)
- # ring-swagger (3)
- # rum (3)
- # shadow-cljs (100)
- # spacemacs (17)
- # sql (10)
- # timbre (2)
- # unrepl (29)
- # yada (2)
@alexisvincent Personally I use one project.clj file and profiles.
Thanks :) I just had an issue with the cljs repl loading a dep that was only meant for server side
@rauh is it possible to specify different profiles for cljs and clj repl
@rauh is it possible to specify different profiles for cljs and clj repl
@alexisvincent Yes, I use something like this for my projects: https://gist.github.com/rauhs/d5bb47c239b58cbf54e1d3d1de221031
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.
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?
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.
@rauh Starting repl from cli feels correct, but do you have any other reasons you think it should be the canonical way?
@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.
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@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)
@rauh Super useful 🙂 Thanks man 🙂
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 :()
I guess 😞
@holyjak I think you can try using https://github.com/binaryage/cljs-oops to solve (3)
Oh, I forgot about that one. You are right, that is perhaps my best option.
have anyone used cljs-pdfkit? I cannot get the namespace resolved 😞
@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
https://clojurescript.org/reference/compiler-options You can also disable "pseudo-names"
in general you are right but I` am writing an AWS Lambda function so small size matters
Then I'd probably just do js/...
interop and use infer externs to automatically get those externs
I do js/require
the library but infer externs does not help, it does not mention the library (`AWS`) at all 😞
(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"
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.
And I don't need js/
. When I switch to .assumeRoleWithSAML
which is in the externs then the code works as is
I think that should report on #cljsjs and commit https://github.com/cljsjs/packages/blob/master/aws-sdk-js/resources/cljsjs/aws-sdk-js/common/aws-sdk-js.ext.js
@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$
)
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.
Where do I place externs? On the classpath, i.e. typically in a resources/mylib.js
?
@holyjak I’m pretty sure we also check file location location relative to Java process dir
Thanks! I think it would be really good to add this info to https://clojurescript.org/reference/compiler-options#externs
will send a PR
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.
Or well, that page is about compiler options so it's probably good. Foreign deps have their own page.
My pleasure!