Fork me on GitHub
#clojurescript
<
2020-05-22
>
tatut05:05:29

Tried converting a big reagent app to use the bundle target and webpack, it seems to work fine locally but production build takes a very long time (from 90 seconds to 16minutes) and some cljsjs deps didn’t work in the advanced compiled output… I should probably just upgrade all the cljsjs deps to their npm versions and not mix npm/cljsjs

didibus06:05:05

Not an expert, but this definitely sounds strange

tatut09:05:19

seems that webpack is the slow part, seeing a node process which is using a single core for most of the duration

plexus07:05:53

I'm following the [Krell reagent tutorial](https://github.com/vouch-opensource/krell/wiki/Reagent-Tutorial), but running clj -m krell.main -co build.edn -c -r I'm getting compiler/analyzer exceptions because it can't find react-dom

plexus07:05:59

should I install react-dom just to satisfy that dependency (even though I imagine it won't be used), or is there a way to not have it compile reagent.dom?

plexus07:05:28

ah I think I missed a step duckie

duckie 4
plexus07:05:28

yay! @dnolen I did have to add a :paths ["src"] to deps.edn, I think that should be updated in the tutorial?

mkvlr07:05:31

@plexus strange, I thought that’s the default in deps

plexus07:05:24

maybe it's a red herring... it wasn't finding awesome_project/core.cljs, when I added it it did

mkvlr07:05:54

it’s at least there on my system by default

mkvlr07:05:56

~/d/testdeps ❯❯❯ echo "{}" > deps.edn
~/d/testdeps ❯❯❯ clojure -Spath
src:/Users/mk/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/Users/mk/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:/Users/mk/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar

dnolen12:05:21

yeah :paths should be set for you, and I haven't heard about that one before from others

Michaël Salihi14:05:19

Yes for me too, src is default included in path without to specify in deps.edn...strange for you @plexus

dominicm14:05:47

That's been the default since very early.

alexmiller14:05:36

since always

Brandon Olivier23:05:20

Is it possible to get webpack tree shaking for a project I'm importing into a cljs project?

Brandon Olivier23:05:36

Specifically, I maintain a react component lib at work, and I'd like to import some of those components into a cljs project.

lilactown23:05:23

@brandon149 what is your CLJS project using to build?

Brandon Olivier23:05:30

I'm using shadow-cljs

lilactown23:05:43

shadow-cljs will only include the JS files that you require

👍 4
Brandon Olivier23:05:46

I'm not married to it, it's just what I'm most familiar with

Brandon Olivier23:05:22

In that case, I need to double check some stuff

lilactown23:05:58

so if you require your JS components in a cljs namespace like:

(ns my-app.feature
  (:require ["component-lib/Foo" :as Foo])) 
it should only include the Foo file and any dependencies of it

lilactown23:05:45

this is assuming some things, like you’re deploying your component library as either CommonJS or ESM

Brandon Olivier23:05:02

ah, right now I require the whole lib and the final bundle is massive

lilactown23:05:13

yeah, this is a common question with component libraries like material-ui

lilactown23:05:22

you can see the example of how to fix this here: https://github.com/thheller/shadow-cljs/issues/412

lilactown23:05:50

I’m not sure how your component library is structured, but the idea is that you want to require just the files that you need and shadow-cljs will handle the rest

Brandon Olivier23:05:41

I never intended it to be consumed by non-js libs, so hopefully it works out 😅

Brandon Olivier23:05:49

Thanks-a-million