This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-30
Channels
- # announcements (2)
- # beginners (87)
- # boot-dev (9)
- # cider (3)
- # cljs-dev (72)
- # clojure (81)
- # clojure-europe (1)
- # clojure-france (1)
- # clojure-italy (1)
- # clojure-nl (2)
- # clojure-russia (212)
- # clojure-serbia (3)
- # clojure-spec (4)
- # clojure-uk (31)
- # clojurescript (82)
- # cursive (15)
- # datascript (2)
- # datomic (27)
- # dirac (11)
- # events (6)
- # fulcro (12)
- # hoplon (3)
- # jobs-discuss (1)
- # klipse (12)
- # off-topic (50)
- # overtone (8)
- # reagent (20)
- # reitit (7)
- # shadow-cljs (1)
hi, trying to follow a d3 example, not sure why the following translation doesn’t work... https://github.com/d3/d3-scale js:
var x = d3.scaleLinear()
.domain([10, 130])
.range([0, 960]);
x(20); // 80
x(50); // 320
cljs:
(require '[cljsjs.d3])
(def x
(-> js/d3
(.scaleLinear)
(.domain [10, 130])
(.range [0, 960])))
(x 20) ;; nil
(x 50) ;; nil
If I do (js/console.log x)
, it prints the following function:
ƒ scale(x) {
return (output || (output = piecewise(domain, range$$1, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate$$1)))(+x);
}
Is there a different way to call x
? I tried many variations of dot forms and js-invoke
with no luck@mbossenbroek try using the #js
tag before those vectors, D3 likely expects JS arrays
https://cljs.github.io/api/syntax/js-literal
(require '[clojure.tools.reader.edn :as edn])
;=> nil
(edn/read-string "#inst \"2010-11-12T13:14:15.666\"")
;=> #error {:message "No reader function for tag inst.", :data {:type :reader-exception, :ex-kind :reader-error}}
@phill It does, (fiddlyness with records being a mess from my perspective). Lots of unobvious steps that I had to do. I was thinking of turning it into a macro, but I don’t have too much experience writing those, so I was worried I’d end up putting together some ghastly thing that would invariably trip me up in future…
@lilactown the end reader doesn't have any reader tags registered by default, as it doesn't use the global var but takes a map parameter
right, I was misremembering -- possibly you're using an earlier version when this wasn't the case
$ rebel-clj 'org.clojure/tools.reader {:mvn/version "1.3.2"}'
[Rebel readline] Type :repl/help for online help info
user=> (require '[clojure.tools.reader.edn :as edn])
nil
user=> (edn/read-string "1")
1
user=> (edn/read-string "#inst \"2010-11-12T13:14:15.666\"")
#inst "2010-11-12T13:14:15.666-00:00"
user=> (require 'clojure.edn)
nil
user=> (clojure.edn/read-string "#inst \"2010-11-12T13:14:15.666\"")
#inst "2010-11-12T13:14:15.666-00:00"
@thheller maybe stupid question, but how did you make shadow-cljs popular on the beginning of the story? How did you spread information to people about your project?
Just thinking how to tell people about library, while it can’t be find in google on the beginning of the story 🙂
i don't understand why you would mix the two. Are you using devcards as your test runner? We only use devcards as a ui test
We've used devcards as a tet runner for a little bit but switched to bruce's cljs test runner. Devcards had some issues with async tests and the cljs test runner is really just a test reporter and uses the normal testing to run so everything is supported
if you switch to https://github.com/bhauman/cljs-test-display i think you will enjoy it more. I think i remember with devcards you need to navigate to the card namespace to run those tests
also the favicon and os notification features of cljs test display make it a real pleasure
My main reason to use devcards as a test runner was to have a visual interface to look at tests, and it seems like what you linked me provides just that
and for my generative tests, I would like to do something like “test passed if I can stest/check 1000 examples on my function and no error is thrown”
also it should be trivial to drop in since devcards exposes the same deftest
and is
forms i think ? you just replace the require statement and should be up and runnin
yup t does; I basically just need to figure out how to set this up with my shadow-cljs tooling, but it shouldn’t be too long
also while you are doing this, if you are using figwheel-main you should look into extra mains. Running tests, devcards, and app simultaneously is a really nice way to work
Is there a way to know which dependency is having big influences on the minified size?
@frozenlock if you’re using shadow-cljs, you can generate a build report: https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report
Not using it 😞
@frozenlock node modules? cljsjs?
cljsjs
I found a stackoverflow asking this in April and it looks like the only answer was “use shadow-cljs” 😕
Another solution is to use fighweel-main with {:npm {:bundles {"dist/index_bundle.js" "src/js/index.js"}}}
https://github.com/kwladyka/form-validator-cljs/tree/doc here is an example of figwheel-main + clj as it is something new and not everybody know about it
https://github.com/kwladyka/form-validator-cljs/blob/doc/src/js/index.js - this is probably the most interesting file
Thank you for the info
I'm still on the old figwheel. I guess I should update anyway. I could use this as an opportunity to try shadow-cljs.
Wait... does shadow-cljs allow you to avoid relying on cljsjs?
also AFAICT even figwheel-main doesn’t give you any mechanism to get a fine-grained bundle size report
I suppose lein-externs can do the job? (I already use it for library minified not on cljsjs.)
Or are externs somehow irrelevant with shadow-cljs?
IME shadow-cljs does a really good job of externs-inference, but there are ways to configure it: https://shadow-cljs.github.io/docs/UsersGuide.html#externs
I think you have better chance to find something which will show you node modules size
@lilactown not true that cljsjs goes through Closure
the only other way is to write Closure compatible JS, like transit-js - but hardly anyone is doing that
so if you’re using something from NPM, or some random JS dep - it’s going to bloat your application, plain and simple
maybe folks should be looking more closely at ClojureScript + https://rollupjs.org/guide/en
this is very long doc. Do you know any example of using it with ClojureScript? Is it really worth to use it vs https://github.com/kwladyka/form-validator-cljs/blob/doc/src/js/index.js ?