clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
p-himik 2020-11-30T02:46:14.048Z

I've never used Webpack but it seems like it's possible: https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module

Nazral 2020-11-30T07:04:37.049900Z

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

rutledgepaulv 2020-11-30T11:56:07.054700Z

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
p-himik 2020-11-30T07:09:08.050Z

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

Nazral 2020-11-30T07:21:47.050200Z

thanks!

Tao Lin 2020-11-30T08:23:18.051900Z

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 Lin 2020-11-30T08:24:17.052500Z

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

simongray 2020-11-30T09:56:25.053Z

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 ...) .

simongray 2020-11-30T09:57:16.053200Z

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-himik 2020-11-30T11:21:30.054Z

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

Tao Lin 2020-11-30T11:48:05.054300Z

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

simongray 2020-11-30T12:41:15.055Z

@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.

Tao Lin 2020-11-30T12:45:09.055300Z

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
niwinz 2020-11-30T15:08:14.058400Z

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...

dnolen 2020-11-30T15:29:14.059300Z

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

dnolen 2020-11-30T15:29:55.060Z

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

niwinz 2020-11-30T15:35:06.062700Z

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...)

william 2020-11-30T16:35:45.063Z

what sat solver would you recommend for clojurescript?

lilactown 2020-11-30T16:53:43.063600Z

Probably a JS one

ns 2020-11-30T19:43:38.065800Z

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!

niwinz 2020-11-30T21:21:38.067Z

@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

2020-12-01T12:28:30.071300Z

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

ns 2020-12-01T20:52:58.072800Z

Guys, thank you so much!

niwinz 2020-11-30T21:22:03.067100Z

We are doing this here: https://github.com/penpot/penpot/blob/develop/frontend/gulpfile.js#L50

thheller 2020-11-30T21:45:26.067800Z

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

ns 2020-12-01T20:53:59.073Z

@thheller Thank you!