This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-21
Channels
- # announcements (2)
- # aws (1)
- # beginners (172)
- # boot (3)
- # calva (19)
- # cider (18)
- # clj-kondo (5)
- # cljsrn (18)
- # clojure (47)
- # clojure-europe (9)
- # clojure-finland (7)
- # clojure-italy (3)
- # clojure-nl (15)
- # clojure-spec (20)
- # clojure-sweden (2)
- # clojure-uk (72)
- # clojurescript (45)
- # cursive (42)
- # datomic (6)
- # duct (4)
- # emacs (4)
- # expound (48)
- # figwheel-main (7)
- # fulcro (64)
- # graphql (8)
- # hoplon (9)
- # hyperfiddle (1)
- # jackdaw (8)
- # jobs (4)
- # jobs-discuss (61)
- # klipse (5)
- # leiningen (6)
- # off-topic (72)
- # pathom (2)
- # planck (11)
- # re-frame (1)
- # reagent (3)
- # reitit (16)
- # remote-jobs (17)
- # ring-swagger (3)
- # shadow-cljs (49)
- # spacemacs (12)
- # sql (3)
- # tools-deps (124)
- # vim (64)
- # xtdb (4)
Hi, I’m quite new to clojurescript coming from js world, i’m reading about re-frame, feels a lot like redux, but doesn’t create a lot of boilerplate at scale ? Like for any single UI change you have to go through the whole dominos process ?
@vnctaing The moment you start using re-frame your sex life will improve, all your skin blemishes will disappear, and your chances of winning either an Oscar or Nobel Prize improves hugely. This has all been rigorously proved (via methods!). Although be aware that some have accused me of bias and it might be best for you to keep reading the docs and drawing your own conclusions :-) But to answer you question, yes, boilerplate reduces (compared to Redux). And, yes, re-frame takes care to ensure that the minimum necessary number of dominoes fall per iteration.
I have a project with shadowcljs, which has a package.json file, which has dependency "react-icons": "^2.2.7"
. I would like to use these react classes but I don't know how to import them in code. I tried adding:
(:require ["react-icons/fa" :refer [FaBeer]] ....
but I get this error:
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es3", :goog-module nil, :js-warnings [], :resource-name "node_modules/react-icons/fa/index.js", :js-requires [], :js-errors [{:line 1, :column 7, :message "'async' expected"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false}
ExceptionInfo: errors in file: /Users/roklenarcic/clojure-projects/cards/node_modules/react-icons/fa/index.js
shadow.build.npm/get-file-info* (npm.clj:531)
shadow.build.npm/get-file-info* (npm.clj:433)
shadow.build.npm/get-file-info (npm.clj:568)
shadow.build.npm/get-file-info (npm.clj:565)
shadow.build.npm/find-resource (npm.clj:659)
shadow.build.npm/find-resource (npm.clj:620)
shadow.build.resolve/find-npm-resource (resolve.clj:109)
have you seen the documentation about how to do imports @roklenarcic? @thheller has amazing docs and walks you through how to figure out the correct import
see Table 1. ES6 Import to CLJS Require
https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages
@roklenarcic it looks like the entire library is shipped as JSX code. shadow-cljs does not support JSX code.
(apologies @roklenarcic i've asked the same question before I knew about these excellent docs)
thheller, that works thanks
(defn foo ^string [^string x])
[(-> #'foo meta), (-> #'foo meta :arglists first meta)]
Why does neither ->
return :tag metadata? I can obtain it in JVM clojure
It would help me make sure my type hints are doing the thing I think they are, allowing me to write metaprogramming tools, and unit tests for thoseOne thing that might be useful for ascertaining what is going on with type hints: https://github.com/mfikes/ilk
For the argument meta, you just need another first
(-> #'foo meta :arglists ffirst meta)
If you set *print-meta*
true, you'll see this in the in the meta for #'foo
:
:tag string,
:arglists ([^{:tag string} x]),
If someone wants to learn about getting started, Electron /w Clojurescript. Message me. I have done it.
@vemv that kind of stuff isn't supported in CLJS. vars don't exist at runtime in CLJS.
But then wow come I can access a variety of metadata keys via var-quote syntax? Is it some kind of sugar?
yes. var is a macro that will create a cljs.core/Var instance with the data from the analyzer
self-hosted has access to the analyzer data at runtime so techncially you could do more stuff
Interesting! I might look into using the s-h version, at least for the test suite of my lib. Might let me do the same crazy stuff I do in my JVM suite (testing macroexpansions, var metadata etc)
hey, one question regarding cljs configuration. I noticed that in order to have a correctly working code-splitting and modules loaded dynamically (with advanced optimization) :output-to
in modules need to start with the same path as :output-dir
(which sets directory for temporary files). for example, when :output-dir
is "scripts/out" module with {:output-to "scripts/out/blah.js"}
config is loaded correcly when required whereas with this config {:output-to "scripts/prod/blah.js"}
the URL that modules is being fetched from is really weird (contains absolute path like http://Users/xxx/projects/yyy/scripts/prod/blah.js). I found the same problem described in boot (https://github.com/boot-clj/boot-cljs/issues/174#issuecomment-328139572), but my question is - is there any way to store generated modules out of :output-dir
?
@michal probably a question for the #boot channel. re: ClojureScript's own behavior - should probably emit a warning about :output-dir
not matching :output-to
@dnolen well, actually my problem is not related to boot (I just found their ticket by chance). let me explain why I need such a combination (modules generated outside of output-dir), maybe my thinking is somewhere wrong. I would like to generate a "distribution" jar without any "temporary files" that cljs generates. unfortunately, resulting modules are created inside the dir where temp files are thrown as well and things get a little bit messy. Having modules generated outside the :output-dir would make it easier to filter them out.
@michal right, we can probably make that work but it's super low priority since this is not a hard thing to work around
or if you're interested in working on that yourself, happy to take a patch that makes that work
Is there a better way to read a clojurescript file as edn than using clojure.edn/read-string
? The result i’m getting is just the ns form but it’s not including the rest. I’m assuming i’m not getting rest because I use some js interop w/ a node library but that’s just a guess.
clojurescript files aren't EDN usually, btw @colinkahn -- you may want to use tools.reader or whatever clojurescript uses