Fork me on GitHub
#clojurescript
<
2020-11-30
>
Nazral07:11:37

I am trying to create a .cljc library from a clojure library I wrote. Unfortunately this library depends on clojure.data.json which is not available in clojurescript, is there a way with leiningen to have some dependencies only when building for clojure, and not for clojurescript? I know I can adapt the functions using clojure.data.json using reader conditionals

p-himik07:11:08

> is there a way with leiningen to have some dependencies only when building for clojure, and not for clojurescript Yes, profiles.

rutledgepaulv11:11:07

Profiles apply at build time but as far as I know you won't be able to ship a single .cljc jar that only sometimes brings additional dependencies to the classpath. So, if your goal is one distribution then it could be without clojure.data.json and you could mention to your users that it's a required additional dependency for using the library from clojure. Or, just always include it since an inflated classpath during clojurescript builds (not distributions) is probably not very important unless the library is something prone to breaking and also used by the clojurescript build chain / compiler.

1
Tao Lin08:11:18

I have a table with 3000 cells, and it's taking forever to render. How can I get it to sparsely rerender when I edit one cell?

Tao Lin08:11:17

I'm using Reagent, and don't want to use other libraries

simongray09:11:25

Do your cells have unique React keys? Usually, the key to solving this in React - and therefore reagent - is to make sure your cells have a unique key, i.e. the stuff you set either in the attr map or via metadata, e.g. ^{:key k} [:td ....] . If every cell has a unique key, then only the cell with changed content needs to be modified. Also, do make sure to make all call all your component functoons with [my-component ...] rather than (my-component ...) .

simongray09:11:16

Keys are the trickiest part of React, IMO. There is unfortunately no one good way to create unique keys; it really depends on your data. Depending on how you data looks you might have to create the uniqueness at the row level instead.

p-himik11:11:30

> sparsely rerender Not just for editing - consider using something like https://github.com/bvaughn/react-window

Tao Lin11:11:05

Thanks! Keys solved most of the problem. I had to use keys on all my intermediate functions in order for that to work though.

simongray12:11:15

@U0125K3M73J It looks like you’re incrementing integers as your keys. Note that this will likely introduce subtle bugs if you ever reorder your data or introduce new data points since your some of your keys then no longer identify the same data points. Also, I recommend keeping your browser developer tools open while developing - that would also have notified you of your missing keys.

Tao Lin12:11:09

They did notify me. I was just confused because I thought my keys would automatically propagate through custom components. About the integer keys, i'll keep that in mind if I reorder them

👍 1
niwinz15:11:14

Hi folks! Someone knowns the correct/proper way to rexport vars from other namespaces? I mean, some kind of reexport. A simple (def foobar someotherns/foobar) works but does not preserves metadata and the compiler does not emit warnings on compile time about wronga arity...

dnolen15:11:14

there is no reexport - I generally just use the pattern found in core.async

dnolen15:11:55

there have been libraries and tools to do this in the past but only works for Clojure and generally yucky in my opinion

niwinz15:11:06

Yeah, I know that clojure has many libraries that does; In my case we have a very big namespaces, for mental process is much simple splitting them, but as public api, we prefer import a single namespace with all the exposed funcions... we have used simple def based reexports, but they are very weak (dont preserves metada (expected), so the compiler emits more arg checks and then does not emit arity warning...)

william16:11:45

what sat solver would you recommend for clojurescript?

lilactown16:11:43

Probably a JS one

ns19:11:38

Hi everyone! Wondering if someone could help me with hashing build files - I understand that there is module-hash-names option for shadow cljs but how do I get that newly built hashed file name into index.html? (other than doing it manually) Thank you for any help!

niwinz21:11:38

@nedim hi, the shadow-cljs generates manifest file (in EDN or JSON), you can generate it in JSON and then pass the proper values to a template generation function for generate the index.html

mathias_dw12:12:30

I just transform the index.html when serving it. In the handler it's easy to read the manifest...

ns20:12:58

Guys, thank you so much!

thheller21:11:26

@nedim see the history in #shadow-cljs answered a couple hours ago