shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
mruzekw 2020-11-18T04:41:30.060700Z

What is the recommended way to split code based on platform for a React Native application? I know there’s custom reader conditionals for .cljc files. Are there any ways to consider? Thanks

thheller 2020-11-18T11:01:19.062400Z

what does "split code based on platform" mean? if its just small snippets of code then reader conditionals make sense

thheller 2020-11-18T11:01:34.062800Z

it its actual full namespaces then it might be better to use separate entry namespaces

thheller 2020-11-18T11:01:53.063100Z

I don't use react-native so I don't know what people usually use

rkiouak 2020-11-18T14:03:08.064700Z

Is there a way to use shadow-cljs to output a cljs .jar? My colleagues and I were just discussing how to declare, for example, a minimum js dependency version in a cljs generated jar, and it seems like https://clojure.atlassian.net/browse/CLJS-1973 is how we’d plug into our existing build, but I note your comment on this ticket, and am not clear if there is an alternative method for declaring js deps in clojurescript output?

thheller 2020-11-18T15:14:33.065600Z

@mrkiouak shadow-cljs does not support creating/publishing .jar files. I use lein to do that. JS deps you declare via :npm-deps in deps.cljs, eg. https://github.com/reagent-project/reagent/blob/master/src/deps.cljs

rkiouak 2020-11-18T15:16:02.066200Z

is that compatible with non cljsjs bundled npm libs now? My understanding was that used to require a cljsjs publish

rkiouak 2020-11-18T15:26:02.066600Z

ah… in testing it i see that it does work without a cljsjs published jar

rkiouak 2020-11-18T15:26:05.066800Z

thanks

orestis 2020-11-18T15:46:35.069300Z

I’m using the build report functionality and it’s super helpful. I’ve shuffled some modules around and I’m seeing a lot of stuff I did not expect into the “base” module. That is, stuff that are perhaps in a required namespace but not actually used in the entry file. Is there I way I can figure out why they are included and perhaps drop hints to shadow-cljs to move them to another module?

thheller 2020-11-18T16:14:52.069900Z

@orestis the logic is always to move dependencies as far "outside" as possible

thheller 2020-11-18T16:15:19.070500Z

if its moved up into base it is likely that you have 2 modules that are separate but depend on c

thheller 2020-11-18T16:15:31.070800Z

since it can't be in a AND b it is moved into the base

thheller 2020-11-18T16:16:09.071300Z

you requires are the only way to control where stuff goes

thheller 2020-11-18T16:16:39.071900Z

or if you absolutely want one namespace in a specific module you just declare it in the module :entries vector

thheller 2020-11-18T16:16:48.072200Z

then it will error out if it gets moved out and tell you why

orestis 2020-11-18T16:27:08.073400Z

Ah, so it’s namespace-level @thheller, right? Not function level like DCE? That makes sense. I will then probably need to split some large namespaces.

thheller 2020-11-18T16:28:47.073800Z

the config is namespace level

thheller 2020-11-18T16:28:51.074100Z

the final split is function level

thheller 2020-11-18T16:29:30.074800Z

in the report you'll often find a namespace split into multiple modules

thheller 2020-11-18T16:30:17.075700Z

but yeah smaller namespaces make for better splits

orestis 2020-11-18T16:47:32.078Z

Hm, I expected namespaces into multiple modules but in my case it’s not happening effectively. I’ll dig around more to see what I can do to affect stuff.

orestis 2020-11-18T16:48:20.079900Z

JS dependencies might also affect this right? I guess they can’t be split as effectively.

thheller 2020-11-18T16:50:16.080300Z

yeah they'll stay in the module they are required in. never moved further.

Jag Gunawardana 2020-11-18T22:41:16.086400Z

Has anyone had any luck using MathJax with shadow-cljs. I’ve done what I normally do (npm install mathjax; and then (:require [“mathjax” :as mj]) …. ) Just keep getting an empty {} when I look at what is in the namespace.