This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-21
Channels
- # announcements (4)
- # architecture (161)
- # autochrome-github (7)
- # babashka (61)
- # beginners (42)
- # calva (24)
- # cider (22)
- # clj-kondo (28)
- # cljs-dev (8)
- # clojure (88)
- # clojure-art (2)
- # clojure-dev (7)
- # clojure-europe (43)
- # clojure-germany (2)
- # clojure-nl (2)
- # clojure-uk (4)
- # clojurescript (32)
- # core-async (41)
- # cursive (32)
- # datahike (6)
- # datomic (9)
- # emacs (22)
- # events (2)
- # fulcro (10)
- # graphql (1)
- # nextjournal (16)
- # off-topic (9)
- # overtone (1)
- # pathom (16)
- # polylith (5)
- # quil (7)
- # rdf (1)
- # re-frame (7)
- # reagent (22)
- # releases (2)
- # remote-jobs (1)
- # reveal (12)
- # sci (1)
- # shadow-cljs (12)
- # specter (20)
- # sql (6)
- # tools-deps (21)
- # vim (26)
- # xtdb (10)
Hi, I’m interested in fixing CLJS-3327 to make CLJS compilation work with bazel. I have a branch that extends closure/module-file-seq
to support multiple node module dirs and replaces references to (io/file "node_modules")
with the or
of the NODE_PATH env var or [(io/file “node_modules”)]. Is that the approach you were thinking of, @dnolen?
Hi! Is there a fundamental lower limit to the file-size of compiled javascript (using :optimizations :advanced
). It seems this lower limit is circa 60kb. I expect this is a rookie question - thanks in advance!
Depends entirely on what you use, since there's DCE (Dead Code Elimination). E.g. a single namespace with no requires and just one function
(defn ^:export main []
(js/console.log "hello"))
ends up being a 504 bytes file for me.thanks @U2FRKM4TW! I ran the hello world example at https://clojurescript.org/guides/quick-start#production-builds and got a minified js file of size 95410 bytes. When I plugged in your code, ie replacing (println ...)
with (js/console.log ...)
the minified file shrank to 2714 bytes.
I must admit I'm lost here. Why the difference?
Because println
does a lot more behind the scenes. One thing leads to another, and in the end a single usage of println
brings almost the whole of CLJS with it. Same is true for e.g. built-in data structures.
That makes sense. So a practical lower limit to expect when using built-in data structures ends up being circa 90kb I guess?
Can't say how accurate that number exactly because it depends on the build tool and on the version of the compiler, but the order of magnitude is around that, yeah.
in any reasonable project actually using stuff from cljs.core
(eg. maps, sets, vectors, etc) then 90kb is reasonable yes
Thanks @U2FRKM4TW and @U05224H0W yes it's an order of magnitude I was curious to know.
Hi, I am using a nested map in cljs and I thought to use some keywords instead of strings as the values
in the nested map and cljs doesn't seem to likey:
(.log js/console
(get-in {:e1 {:type "snackbar"}} [:e1 :type]))
=> "snackbar"
(.log js/console
(get-in {:e1 {:type :snackbar}} [:e1 :type]))
=> ()
so I guess this might be the custom formatter returning an empty list? but console.log output doesn't show up in the repl
Ah yeah it's probably console log not sharing all the deets
Oh it's there, I was overlooking the output
{ns: null, name: 'snackbar2', fqn: 'snackbar2' ....
need to call str
😃
I put a custom data tag on a span
, which contains a string. But when I try to read the data tag of that span from another part of the codebase, I get:
Cannot infer target type in expression (. (. (. selection -anchorNode) -parentElement) -data-start)
Googling around, it seems that I could solve this with more externs, but isn't there a way to say "actually I know that -data-start
should be a string?I don't think it talks about the type of -data-string
specifically. Adding ^js
in front of selection
should fix it.
Was about to say. :) It's node.dataset.start
in JS: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
thank you guys, in fact using -dataset -start
at the end of the chain was what was needed! But at that point, I didn't need the ^js
hint either. So, is the original error message in general a hint that the attribute might not be there? Why not just say that?
But even if it does know that - suppose the error is "The attribute data-start
might not be there."
How is it more useful? The end result is still the same - someone that knows what's up with externs will know what the error means, and someone that doesn't know will still have to figure it out.
yes I guess what tripped me here is that it doesn't seem to me that "externs" are in any way involved (as I think of them as needed when there's some interop with another library - maybe I'm wrong). This is just a "I put some data in the dom and want to retrieve it in the next function"