I've never used Webpack but it seems like it's possible: https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module
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
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.
> is there a way with leiningen to have some dependencies only when building for clojure, and not for clojurescript Yes, profiles.
thanks!
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?
I'm using Reagent, and don't want to use other libraries
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 ...)
.
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.
> sparsely rerender Not just for editing - consider using something like https://github.com/bvaughn/react-window
Thanks! Keys solved most of the problem. I had to use keys on all my intermediate functions in order for that to work though.
@taoroalin 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.
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
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...
there is no reexport - I generally just use the pattern found in core.async
there have been libraries and tools to do this in the past but only works for Clojure and generally yucky in my opinion
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...)
what sat solver would you recommend for clojurescript?
Probably a JS one
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!
@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
I just transform the index.html when serving it. In the handler it's easy to read the manifest...
Guys, thank you so much!
We are doing this here: https://github.com/penpot/penpot/blob/develop/frontend/gulpfile.js#L50