Fork me on GitHub
#shadow-cljs
<
2020-11-18
>
mruzekw04:11:30

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

thheller11:11:19

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

thheller11:11:34

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

thheller11:11:53

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

rkiouak14:11:08

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?

thheller15:11:33

@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

rkiouak15:11:02

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

rkiouak15:11:02

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

orestis15:11:35

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?

thheller16:11:52

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

thheller16:11:19

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

thheller16:11:31

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

thheller16:11:09

you requires are the only way to control where stuff goes

thheller16:11:39

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

thheller16:11:48

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

orestis16:11:08

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.

thheller16:11:47

the config is namespace level

thheller16:11:51

the final split is function level

thheller16:11:30

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

thheller16:11:17

but yeah smaller namespaces make for better splits

orestis16:11:32

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.

orestis16:11:20

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

thheller16:11:16

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

Jag Gunawardana22:11:16

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.