Fork me on GitHub
#clojurescript
<
2019-02-21
>
stathissideris08:02:39

I’m using this in an attempt to get an AST for my cljs source: (cljs/cljs.analyzer.api (File. filename)) But it fails with No such namespace: cljsjs.react which is a transitive dependency to my project via re-frame. Is it a problem with the project setup or am I using the analyzer incorrectly?

thheller08:02:11

@stathissideris the analyzer must be initialized with the :foreign-lib data from deps.cljs files

thheller08:02:58

I'm not quite sure what call that was. you'll probably find it in cljs.closure

stathissideris08:02:44

@thheller thanks for the pointer, I’ll look into it

stathissideris08:02:49

@thheller does it make any difference that my project uses cljsjs deps only?

thheller08:02:38

well it would be much more difficult if it didnt 😉

thheller08:02:58

deps.cljs files contains the foreign lib definitions mapping the cljsjs.* namespaces back to some JS files

thheller08:02:35

something about upstream deps IIRC

stathissideris08:02:53

oh, I see, it’s under add-implicit-options in the build function. Thanks!

borkdude09:02:02

Why does Node want to allow incoming connections? hmm

thheller09:02:10

@borkdude because it starts a server that the REPL code will connect to and exchange messages

borkdude09:02:21

does this connection have to go beyond the firewall?

borkdude09:02:11

then why does MacOS complain about this? I don’t see this with any other REPLs I use 🙂

thheller09:02:04

probably because it just listens on a given port and not limited to 127.0.0.1

borkdude09:02:52

probably on the wildcard address, which is not a good default

anish09:02:30

Hi I have above Js code that i want to write in Cljs

anish09:02:46

I was wondering is that correct?

thheller09:02:17

depends on what icon and the rest are

anish10:02:32

thanks @thheller, icon and text are corresponding cljs classes, but as in Js TouchableOpacity component wraps Icon and Text I am assuming same behavior as in touchable-opacity would wrap icon and text classes

Whiskas13:02:10

Which chart lib do you guys like using with clojurescript?

Whiskas14:02:20

@paul931224 hey, did you use it with react-chartjs?

superancetre14:02:34

Not the person you asked to, but I used chartjs without react-chartsjs but I heard good things about it!

dabrazhe14:02:12

I am looking for slides or transcript of ClojureScript for Skeptics by Derek Slager, does anyone have seen them?

paul93122415:02:24

@mateus.pimentel.w nope, I used it with interop. I use reagent, render a canvas, and with component-did-mount I initialize ChartJs

paul93122415:02:14

not that flexible, because at new data you have to re-render, so giving new parameters is not enough. But it works pretty well for me.

dpsutton18:02:39

anyone know where the array-map/hash-map size is dictated in the cljs codebase? I see this in the changes.md * CLJS-1650: cljs.reader/read-map` now returns array-map/hash-map based on the size of the sequence.` but readmap doesn't seem to be defined any longer

dnolen18:02:14

there's not one place

dnolen18:02:22

it needs to work both at compile time and runtime

dpsutton18:02:58

ah ok. i was able to trace it to clojure.tools reader and then back to (set! (.-HASHMAP-THRESHOLD PersistentArrayMap) 8)

dnolen18:02:47

right that's the runtime one

dpsutton18:02:08

where can i find out the compile time one. that surprised me

dnolen18:02:25

you need to be consistent with literals

dnolen18:02:47

look in the compiler

dnolen18:02:01

at how hashmaps are emitted

dpsutton18:02:46

ok. thanks for the pointers

chancerussell21:02:28

Here’s a dumb one. I’m using clojure.data.xml under clojurescript in the node environment, which uses XMLSerializer and DOMParser globals (which do exist in the browser). I have a node library that has perfectly good DOMParser and XMLSerializer implementations and have validated that they’ll work for my purposes by monkey-patching them onto the global object

chancerussell21:02:45

Now I’m left with the mystery of how to do that monkey patching for a real build

chancerussell21:02:41

Basically, I need js/DOMParser and js/XMLSerializer to exist before I load clojure.data.xml

chancerussell21:02:29

They don’t actually have to point to the real implementations I’m going to use—can hook that up at call time—but something has to be there to get c.d.xml to load

chancerussell21:02:22

Another way to put it might be “I need to run two lines of some dumb arbitrary javascript before I load all my cljs stuff” 🙂

thheller21:02:51

@chancerussell easiest way is to create a namespace that you'll require before you require clojure.data.xml

thheller21:02:04

in that namespace you do (set! js/goog.global.DOMParser ...)

thheller21:02:46

so (:require [your.xml-setup] [clojure.data.xml ...])

chancerussell21:02:57

@thheller That was my first approach but it didn’t seem to actually be working. Maybe I was missing something in the dependency tree, though

chancerussell21:02:50

Seemed like my setup code was somehow running after clojure.data.xml loaded up and threw

thheller21:02:53

as long as you ensure it is loaded before you first use clojure.data.xml you should be fine

chancerussell21:02:14

but now that I’m describing that impression I’m realizing it doesn’t actually make sense 😛