Fork me on GitHub
#shadow-cljs
<
2018-02-07
>
mjmeintjes03:02:47

@bfast I'm using material-ui-next directly from npm with shadow-cljs, and it works great. For me it was a bit difficult figuring out how to require the different components, as some require using default and some require using refer. Here's my current imports, maybe that will help:

["material-ui/Button/Button" :default Button]
   ["material-ui/IconButton" :default IconButton]
   ["material-ui/Progress/LinearProgress" :default LinearProgress]
   ["material-ui/Radio/Radio" :default Radio]
   ["material-ui/Radio" :refer [RadioGroup]]
   ["material-ui/Form" :refer [FormLabel FormControl FormControlLabel FormHelperText]]
   ["material-ui/Switch" :default Switch]
   ["material-ui/Dialog" :default Dialog]
   ["material-ui/AppBar/AppBar" :default AppBar]
   ["material-ui/Toolbar" :default Toolbar]
   ["material-ui-icons/Menu" :default MenuIcon]
   ["material-ui-icons/Close" :default CloseIcon]
   ["material-ui-icons/MoreVert" :default MoreVertIcon]
   ["material-ui-icons/ExpandMore" :default ExpandMoreIcon]
   ["material-ui-icons/ExpandLess" :default ExpandLessIcon]
   ["material-ui/Menu" :default Menu :refer [MenuItem]]
   ["material-ui/Typography" :default Typography]
   ["material-ui/Card/Card" :default Card]
   ["material-ui/Avatar" :default Avatar]
   ["material-ui/Card" :refer [CardHeader CardMedia CardContent CardActions]]
   ["material-ui/Paper" :default Paper]
   ["material-ui/transitions/Collapse" :default Collapse]
   ["material-ui/TextField" :default TextField]
   ["material-ui/Drawer/Drawer" :default Drawer]
   ["material-ui/List/List" :default List]
   ["material-ui/List" :refer [ListItem ListItemIcon ListItemText]]
   ["material-ui/Divider" :default Divider]
   ["material-ui/ExpansionPanel/ExpansionPanel" :default ExpansionPanel]
   ["material-ui/ExpansionPanel" :refer [ExpansionPanelDetails ExpansionPanelSummary]]
Using the components is then simple, just use the special :> operator reagent provides, for example [:> Card {} ]

mynomoto10:02:12

@mjmeintjes that :> seems very interesting, I have been using reagent for a long time and I have never heard of it. Can you point me to some docs?

colindresj17:02:08

For those interested, just thought I post some pretty cool info: we’ve been porting over a large CLJS app from lein-cljsbuild + a lot of cljsjs and manually created foreign libs over to shadow-cljs and completed that task this morning. The productivity gains are one thing, but tangibly we’ve gone from an uncompressed 9.9MB build to 2.7 MB and gziped 1.4MB to ~700k

colindresj17:02:24

Layer on the potential benefits form code-splitting, and that’s a a huge win for us thanks to shadow-cljs

justinlee17:02:50

wow interesting @colindresj. Where do you think most of the gains are coming from? I knew that shadow-cljs made it easier to import, but I didn’t realize it would do better at minification

colindresj17:02:56

Haven’t done a deep-enough dive to figure it out just yet @lee.justin.m, but I’m guessing that since foreign libs (including those in cljsjs) don’t go through any kind of optimization, there’s a lot of duplication and dead code there

colindresj17:02:29

Especially when using JS libraries that are pre-compiled via Babel, I’ve noticed that a lot of our foreign libs contain the same Babel helpers over and over again

dominicm17:02:25

I'd be interested in knowing about the optimization benefits too. I had not considered the duplication before, very interesting.

dominicm17:02:59

I suppose duplication matters little with gzip though?

justinlee17:02:22

the biggest thing that I know shadow allows you to do is reference partial components. e.g. material-ui lets you refer to just the component you are using. that’s actually possible to do in shadow

justinlee17:02:15

if you set your foreign-lib up properly, you should be pointing to minified builds during production. if you guys were doing that and you are still seeing gains, that would be pretty amazing

orestis17:02:20

Gzip takes care of shipping the code to the browser, but the browser still has to parse and execute all the duplicate stuff.

colindresj20:02:52

@dominicm I think so, which is why the gains at the point of gzip are proportionally much smaller than pre-gzip

colindresj20:02:31

@lee.justin.m we were minifying our own foreign libs, hard to know for sure about all the others

thheller20:02:35

@colindresj nice! biggest gain is probably from de-duping some stuff. closure :simple mode (which is used for npm deps) is also pretty good though, so thats part of it too.

thheller20:02:55

but you essentially validated exactly why I wanted to get away from cljsjs. https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-the-problem.html#cljsjs

thheller20:02:07

glad I'm not the only one seeing those results

pepe20:02:02

Hi, I am trying to use beicon with shadow-cljs on node, but getting this: The required namespace "beicon.impl.rxjs" is not available, it was required by "beicon/core.cljc". I skimmed last couple of days and found some similar stuff but somehow I can't get my head around it. The problem I guess is that beicon is using https://github.com/funcool/beicon/blob/master/assets/deps.cljs and it is not compatible with shadow-cljs.

thheller20:02:26

npm install rxjs

thheller20:02:21

I'm not entirely sure how the shim file would have to look

thheller20:02:05

(ns beicon.impl.rxjs
  (:require ["rxjs/Rx" :as rx]))

(js/goog.exportSymbol "Rx" rx)

thheller20:02:59

rx is one of those packages where you are better off importing only what you need directly

pepe20:02:48

Ok, I will try it

pepe21:02:31

So at least compilation is working. I will report how it will continue. I started to play with shadow this week and I fell in love.

pepe21:02:31

So this is my first try with small node library. If I manage to work with it, I am planning to move our front-end app to it

pepe21:02:36

Thank you very much again

pepe21:02:34

Well everything is working for me

thheller21:02:38

hehe I did a quick test and rxjs loads 400+ files

thheller21:02:43

thats a bit scary 😛

thheller21:02:56

but it seems to work

pepe21:02:10

It does indeed