This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-24
Channels
- # architecture (7)
- # beginners (73)
- # boot (4)
- # cider (48)
- # cljsjs (7)
- # cljsrn (27)
- # clojure (206)
- # clojure-boston (2)
- # clojure-italy (21)
- # clojure-nl (8)
- # clojure-spec (7)
- # clojure-uk (94)
- # clojurescript (126)
- # clojutre (7)
- # core-async (3)
- # cursive (7)
- # data-science (1)
- # datascript (4)
- # datomic (6)
- # duct (1)
- # emacs (19)
- # figwheel (1)
- # fulcro (31)
- # graphql (13)
- # jobs (5)
- # jobs-discuss (42)
- # keechma (4)
- # leiningen (10)
- # luminus (3)
- # mount (2)
- # nyc (3)
- # off-topic (37)
- # om-next (3)
- # onyx (45)
- # pedestal (2)
- # re-frame (4)
- # reagent (2)
- # reitit (16)
- # shadow-cljs (118)
- # spacemacs (10)
- # tools-deps (8)
- # vim (20)
assuming you are using Figwheel or some other hot reloading scheme those two can bring you a bit closer to “classic” IDE-centric debugging experience
I realized that i had not included dirac as dependency on my project.. and definitely not in nrepl as middleware. This may be the reason for the issue i mentioned above
no, you were just missing the REPL feature of Dirac, but the debugging part should work independently
unfortunately there are some bugs in source-mapping support in DevTools and some more complex clojurescript-generated javascript code causes confusion in DevTools debugger UI, like this https://github.com/binaryage/dirac/issues/53, also generated code which tends to produce long lines with a lot of javascript statements tends to hit DevTools debugger limits and UX issues (e.g. placing breakpoints to proper locations)
I'm using some foreign-libs (bundled by webpack) in my cljs project. Is there any way to let the compiler do tree-shaking/dead code elimination on the foreign js? For example, I'm using only 4 components from materialize-css and don't need the code of the other components.
@burke shadow-cljs does DCE on npm modules. If that's not a option you could just bundle what you need, for example create a webpack project with an entry point index.js
:
import { foo , bar } from "foobar-lib";
var exports = {};
exports.foo = foo;
exports.bar = bar;
module.exports = export;
then use webpack to get a production build e.g. bundle.js
containing just what you need.
Than in :foreign-libs
:
:foreign-libs [{:file "libs/bundle.js"
:provides ["foobar-lib"]}]
@fbielejec I think I will try shadow-cljs. Tweaking the webpack entry point seems too manually.
@burke @fbielejec shadow-cljs does not do much DCE of node_modules
. only :simple
optimizations are applied to npm
sources. you'll still get better result that webpack
probably but it mostly depends on what you require.
I hope that It'll be worth the effort. My project is a mix of cljsjs and webpack-bundle(everything that was not available in cljsjs). Unfortunately the cljsjs packages I used aren't in shadow-cljsjs 😫
@burke what do you hope to gain from this? bundle size reduction?
@pesterhazy yes I think so.
personally I'm thinking that running non-closure-aware js libs through GCC is a bit risky. I'd rather have slightly larger bundles and things guaranteed to work (as in the "double bundle" method)
I thought that this is one of the main features of the gcc. I dont know.. is it okay to have cljs app of >2mb?
@burke is that post-gzip? it's the size after gzip that counts
I'm not arguing against using gcc for your cljs deps, only raising a question about applying it to foreign libs
@pesterhazy its pre-gzip. Download time is okay because of gzip compression. But it feels like wasting memory and processing time if the js-interpreter on the client has to interpret 30% that isnt needed in the app. I thought that gcc is able to optimize it, but maybe you're right; better have a working app than a small app
stop talking about GCC as if it only did one thing. running things through GCC can mean many things. 🙂
codemirror, quill, katex, chartjs. I've added the necessary namespaces and use your shadow-cljsjs. So the compiler is happy now
if you control the namespaces using those you can directly use the npm packages via (:require ["codemirror" :as cm])
as well. no need to go through the cljsjs
wrappers
Some Cljsjs packages (like Codemirror) also provide npm-style name (`codemirror`) so you could update your app or libs to use that name, so it will work with both shadow-cljs/cljs npm-deps/cljsjs
And it should be easy to update other cljsjs packages to also provide npm-style names
Its a dependency that is also one of my projects, but I dont want to change every project when I'm not sure if this switch to shadow-cljs will be successful. @U061V0GG2 I will try this, good to know.
@burke ClojureScript / Closure JS Module support can allow transpilation of CJS/ES6 modules to Closure modules which allows Closure optimizations. This is what ClojureScript uses when using Node Modules. But as mentioned by @pesterhazy, this can have problems (not many npm packages work yet) and the feature is experimental.
Cljsjs packages could also use Closure module transpilation but none currently do.
In clojure I seem to be able to do this:
(binding [*ns* (the-ns 'foo.bar)] (eval '(foo)))
But clojurescript does not like neither the-ns
, nor eval
.I remember some discussion about eval
in ClojureScript, I think Planck recently added it, but it’s not an option for the non-self-hosted version…
You can mess with eval
in ClojureScript but it ends up needing self-hosted ClojureScript to do it. This might be of interest: https://gist.github.com/mfikes/66a120e18b75b6f4a3ecd0db8a976d84
what is the go-to react component when I need a data table (preferably with collapsible rows) these days?
this seems ok https://react-table.js.org
Yes, that looks very nice. Some of the examples breaks and some get a lot of complaints in the console, but that could be the demo that is out of sync, I guess. Most of it seems to work.
Hi guys, I am wondering what is the idiomatic way of updating a js array within an js object?
I have been reading that I should use goog.object/get
and goog.object/set
for js objects and use aset
and aget
for js arrays.
For example:
#js{:k1 #js [1 2 3] :k2 "v2"}
I want to update index 0 of :k1
I can do (aset obj "k1" 0 "new val")
but that does not seem to fit with not using aset on objects.@jamesthibaudeau I think I would do (aset (.-k1 obj) 0 "new val")
or maybe (-> (.-k1 obj) (aset 0 “new val”))
I want to get away from the .-
way to avoid unexpected symbol munging in advanced compile, but it does makes sense to use goog.object/get
to get the array and aset
to change a value in the array.
In this problem, is the original object actually meant to be the following?
#js {:k1 #js [1 2 3] :k2 "v2"}
@thheller I reviewed the different options a while ago and didn't come up with a clear winner
react-virtualized supports very large tables but isn't a full datatable solution
cool. it's not even in this list: https://github.com/brillout/awesome-react-components#table--data-grid
@mfikes yeah that was what I meant sorry
It’s too bad there is no goog.object/setValueByKeys
, but I suppose you can compose a goog.object/getValueByKeys
with a goog.object/set
to mutate something deeply nested in a JavaScript object.
disregard. it occurs to me I should be able to accomplish almost the same thing with promesa/alet
I required a nodejs library, (require '["crypto" :as crypto])
, and now I want to be able to print all of the functions within this namespace. How do I get them? Within the repl, stuff like (ns-publics crypto)
are returning {}
.
Using lumo repl and clojurescript 1.9.x
cljs.user=> (require 'crypto '[goog.object :as gobj])
cljs.user=> (filter (comp fn? (fn [x] (gobj/get crypto x))) (js/Object.keys crypto))
one way of doing it
Okay, interesting. Thank you. I'll play with that.
Is this more work because it's a foreign import?
I'm guessing yes.
This is very strange... I can't :require any namespaces I've created
clojure.lang.ExceptionInfo: voke.state.events does not exist
Errors in the figwheel repl, I know for a fact the namespace exists and I've tried making other namespaces too@alice since weeks I am trying to figure out this exact same problem. I am totally lost here. Did you find anything?
One simple thing to check is that your ns
declarations match your filesystem paths. Not that I’ve ever made that mistake…I ah…know other people who have.
eval (class 'map)
for example
in cljs "class" is not a thing
voke.core> (class 'map)
---- Compiler Warning on <cljs form> line:1 column:2 ----
Use of undeclared Var voke.core/class
1 (class 'map)
^---
---- Compiler Warning ----
#object[TypeError TypeError: voke.core.class$ is undefined]
nil
how are you requiring?
have you tried requiring from the repl?
(require 'voke.state.events)
something weird I notice is that I can't get that error message in any environment I've tried
clojure.lang.ExceptionInfo: voke.state.events does not exist
at clojure.core$ex_info.invokeStatic (core.clj:4739)
clojure.core$ex_info.invoke (core.clj:4739)
cljs.repl$ns__GT_input.invokeStatic (repl.cljc:202)
cljs.repl$ns__GT_input.invoke (repl.cljc:198)
cljs.repl$load_namespace.invokeStatic (repl.cljc:217)
cljs.repl$load_namespace.invoke (repl.cljc:208)
cljs.repl$load_dependencies.invokeStatic (repl.cljc:245)
cljs.repl$load_dependencies.invoke (repl.cljc:241)
cljs.repl$evaluate_form.invokeStatic (repl.cljc:547)
cljs.repl$evaluate_form.invoke (repl.cljc:484)
cljs.repl$eval_cljs.invokeStatic (repl.cljc:672)
cljs.repl$eval_cljs.invoke (repl.cljc:665)
clojure.lang.Var.invoke (Var.java:396)
figwheel_sidecar.repl$catch_warnings_and_exceptions_eval_cljs.invokeStatic (repl.clj:286)
figwheel_sidecar.repl$catch_warnings_and_exceptions_eval_cljs.invoke (repl.clj:278)
clojure.lang.Var.invoke (Var.java:396)
cljs.repl$repl_STAR_$read_eval_print__6536.invoke (repl.cljc:957)
cljs.repl$repl_STAR_$fn__6542$fn__6551.invoke (repl.cljc:998)
cljs.repl$repl_STAR_$fn__6542.invoke (repl.cljc:997)
cljs.compiler$with_core_cljs.invokeStatic (compiler.cljc:1285)
cljs.compiler$with_core_cljs.invoke (compiler.cljc:1274)
cljs.repl$repl_STAR_.invokeStatic (repl.cljc:960)
cljs.repl$repl_STAR_.invoke (repl.cljc:839)
cemerick.piggieback$run_cljs_repl.invokeStatic (piggieback.clj:169)
cemerick.piggieback$run_cljs_repl.invoke (piggieback.clj:155)
clojure.lang.AFn.applyToHelper (AFn.java:171)
clojure.lang.AFn.applyTo (AFn.java:144)
clojure.core$apply.invokeStatic (core.clj:661)
clojure.core$apply.invoke (core.clj:652)
cemerick.piggieback$evaluate.invokeStatic (piggieback.clj:259)
cemerick.piggieback$evaluate.invoke (piggieback.clj:255)
clojure.lang.Var.invoke (Var.java:381)
cemerick.piggieback$wrap_cljs_repl$fn__36179$fn__36181$fn__36182.invoke (piggieback.clj:291)
cemerick.piggieback$enqueue$fn__36165.invoke (piggieback.clj:247)
clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__32431.invoke (interruptible_eval.clj:190)
clojure.lang.AFn.run (AFn.java:22)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
java.lang.Thread.run (Thread.java:748)
I have no idea, maybe put all in a public repo so that someone can give you a hand
@alice since weeks I am trying to figure out this exact same problem. I am totally lost here. Did you find anything?
everyone gets the weird errors from time to time 🙂
Could someone please explain why I see double vector brackets on some anonymous functions?
hunting for one ...
Okay, the Matchbox (cljs firebase connector) quick spin has..
`(m/listen-children root [:users :mike :friends] (fn [[event-type data]] (prn data)))`
[[event-type data]] means the function takes a vector argument with two members, event-type and data respectively
Cool. Makes sense. So the arity is technically one, and that one thing is a vector with 2 elements
awesome. high five
so in that case, image is a map and you're grabbing :filename, :tempfile, and :size ?
okay, while i have your attention, do you know what the heck is going on here..
https://clojure.org/guides/destructuring Here's the corresponding bible verse to today's lesson
lol corresponding bible verse
cool. thanks for taking a look anyway.
just one of those things it's impossible to google for
my name is backslash colon hyphen the 3rd
when* i figure out what it is. >=)
well I found the actual code on the repo
https://github.com/jakemcc/backgammon/blob/master/src/cljs/bg/subs.cljs#L74
woo, here it is! (in the reframe reg-sub code) "syntactic sugar"
https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/subs.cljs#L128
@alice since weeks I am trying to figure out this exact same problem. I am totally lost here. Did you find anything?