This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-09
Channels
- # aws (1)
- # babashka (61)
- # bangalore-clj (5)
- # beginners (83)
- # biff (2)
- # calva (4)
- # cider (6)
- # clara (5)
- # clj-kondo (72)
- # cljs-dev (31)
- # cljsrn (28)
- # clojure (8)
- # clojure-australia (1)
- # clojure-europe (19)
- # clojure-france (1)
- # clojure-losangeles (21)
- # clojure-nl (2)
- # clojure-spec (2)
- # clojure-uk (9)
- # clojurescript (13)
- # clojureverse-ops (5)
- # code-reviews (1)
- # conjure (7)
- # cursive (4)
- # datascript (2)
- # datomic (8)
- # depstar (1)
- # emacs (3)
- # etaoin (1)
- # events (3)
- # exercism (7)
- # fulcro (6)
- # girouette (2)
- # graalvm (125)
- # honeysql (19)
- # integrant (1)
- # jobs (12)
- # lsp (1)
- # numerical-computing (1)
- # off-topic (23)
- # portal (12)
- # practicalli (1)
- # re-frame (35)
- # reitit (5)
- # releases (1)
- # remote-jobs (1)
- # shadow-cljs (51)
- # tools-deps (14)
- # vim (3)
- # xtdb (20)
Reading through the newest DHH rants, wondering if cljs can produce import maps instead of a single bundle
https://world.hey.com/dhh/rails-7-will-have-three-great-answers-to-javascript-in-2021-8d68191b https://world.hey.com/dhh/modern-web-apps-without-javascript-bundling-or-transpiling-a20f2755
If you are looking to compile to ES modules, check out the shadow-cljs :esm
build, it's the only thing that currently works
CLJS advanced compilation is like lycanthropy: most of the time you don't notice it too much, it gives you abilities that others have to do a ton of work to get in other ways, and every full moon or so it causes a serious problem that only experts understand why it happened
we have :advanced
precisely so that we don't have to worry about all the nonsense the JS world is doing 🙂 import maps or esm don't fix those things
@U4YGF4NGM What kind of a rare but serious problem have you encountered from :advanced ? The only problem I’ve ever encountered, I think, is from missing externs.
… Which granted, is annoying the first 10 times you encounter them 🙂 After than, I learned how to type hint everything properly, and the auto-generated externs take care of that.
there was the time that names generated via advanced compilations collided with minified code from google analytics 😄
I am also now very conscious of the fact that static keywords get lifted into a global constants table, after debugging some code that used React's useMemo
+ a keyword for detecting when it should recompute. turns out the code was buggy, but it wasn't caught in development because a new keyword was being constructed every render; once it went to production, the keyword wasn't constructed every render which triggered the bug
@U4YGF4NGM Ah, thanks for the explanation. Was the code using references (identical? …) or values (= …) to check if it should re-render?
usememo compares objects by reference which is why it was breaking in prod (or not breaking in dev)
I’ve had something similar happen when using memoized components where if you have nested components, the inner component would not re-render unless the outer one re-renders
(let [status (if succeeded? :success :fail)
;; recompute something anytime the status changes
computed-data (react/useMemo #(expensive-computation data) #js [status])]
(react/useEffect
;; send the data to the API anytime it changes
#(api/update-state! computed-data)
#js [compute-state]))
this displays the essence of the problem, though it's reverse - in dev, this will call update-state!
every render, since it will reconstruct a new keyword for status
every render. whereas in prod it will work as expectedhowever if your usage of JS is precise and you don't need a lot of it, and you tightly control your deps then what DHH is proposing is definitely a big simplification
we also live in a world where like almost 40% of JS dev is now in TypeScript - so I don't know
compile steps for JavaScript are never going to go away - and once your application get large enough tree-shaking and minification are must (which DHH largely ignores, but you cannot ignore it)
if you're waiting a non-advanced compiled ClojureScript - you'll be waiting for a very long time 🙂
DHH is also a maintainer and advocate of hotwired.dev which is an attempt to move more UI behavior to the backend
he's on the "tasteful sprinkle of JS" side of things rather than building an entire app in the browser.
with all the obvious tradeoffs- I've heard mixed reviews of http://hey.com's UI, which uses it