Fork me on GitHub
#clojurescript
<
2022-02-21
>
arohner11:02:17

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?

p-himik11:02:58

FWIW, there's #cljs-dev

Mícheál Ó Catháin15:02:00

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!

p-himik15:02:53

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.

Mícheál Ó Catháin16:02:54

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.

Mícheál Ó Catháin16:02:07

I must admit I'm lost here. Why the difference?

p-himik16:02:26

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.

Mícheál Ó Catháin16:02:54

That makes sense. So a practical lower limit to expect when using built-in data structures ends up being circa 90kb I guess?

p-himik16:02:29

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.

thheller16:02:49

in any reasonable project actually using stuff from cljs.core (eg. maps, sets, vectors, etc) then 90kb is reasonable yes

Mícheál Ó Catháin16:02:31

Thanks @U2FRKM4TW and @U05224H0W yes it's an order of magnitude I was curious to know.

sova-soars-the-sora15:02:59

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"

sova-soars-the-sora15:02:12

(.log js/console
  (get-in  {:e1 {:type :snackbar}} [:e1 :type]))
=> ()

p-himik15:02:43

That looks bizarre. What does your REPL output when you evaluate just :snackbar?

p-himik15:02:54

Or (js/console.log :snackbar).

p-himik15:02:12

And what REPL are you using?

thheller16:02:46

console.log doesn't have a return value normally

thheller16:02:21

so I guess this might be the custom formatter returning an empty list? but console.log output doesn't show up in the repl

thheller16:02:55

or why the console.log? why not just the get-in?

sova-soars-the-sora01:02:31

Ah yeah it's probably console log not sharing all the deets

simongray09:02:02

prn is your friend

🐝 1
sova-soars-the-sora15:02:31

Oh it's there, I was overlooking the output

{ns: null, name: 'snackbar2', fqn: 'snackbar2' ....

sova-soars-the-sora15:02:38

need to call str 😃

Carlo16:02:03

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?

p-himik16:02:29

I don't think it talks about the type of -data-string specifically. Adding ^js in front of selection should fix it.

🙌 1
thheller16:02:16

-data-start is not how you get a data-start="val" value from the DOM element

🙌 1
thheller16:02:06

but yeah the inference warning wants a ^js hint on selection

Carlo17:02:29

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?

thheller17:02:57

because it doesn't know that

p-himik18:02:22

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.

Carlo20:02:54

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"