This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-13
Channels
- # announcements (12)
- # babashka (42)
- # beginners (45)
- # calva (60)
- # cider (6)
- # circleci (1)
- # clj-kondo (18)
- # clojure (21)
- # clojurescript (36)
- # conjure (13)
- # cursive (2)
- # datahike (5)
- # datomic (4)
- # depstar (17)
- # emacs (4)
- # fulcro (3)
- # honeysql (2)
- # jobs (2)
- # jobs-discuss (9)
- # lsp (98)
- # malli (32)
- # off-topic (36)
- # other-languages (2)
- # overtone (4)
- # re-frame (5)
- # reveal (7)
- # rewrite-clj (47)
- # shadow-cljs (25)
- # spacemacs (4)
- # vim (7)
is there a recommended way of running other background processes (asset processors, static site builders etc) together with shadow-cljs watch
?
FWIW I found https://www.npmjs.com/package/concurrently which seems works really nicely for my use-case
I have used https://www.npmjs.com/package/foreman https://www.npmjs.com/package/npm-run-all in the past
alright, thanks!
Hey team, is there a recommended article / resource, that goes into the “most idiomatic setup” for css with shadow? Would love any pointers!
Hey team, I am playing around with optimizing my shadow-cljs bundle. I ran
npx shadow-cljs run shadow.cljs.build-report app report.html
One thing I noticed, is that currently the clojurescript runtime is taking 400kb. That seems surprising — I thought it would be doing some kind of tree-shaking. (To test, I deleted all code in core.cljs
, and left the imports)
Here’s my shadow config in project.clj:
{:nrepl {:port 7002}
:builds
{:app
{:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:entries []}}
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
:devtools {:preloads [day8.re-frame-10x.preload]
:watch-dir "resources/public"}}
:test
{:target :node-test
:output-to "target/test/test.js"
:autorun true}}}
I may be missing something trivial. (perhaps I need to manually set a certain kind of :optimizations? Any pointers / resources for debugging further would be appreciated!so you should get rid of those at least (which will also further shrink cljs.core in the process)
Okay, looks like the two biggers culprits:
I have a
/dev/…/app.cljs
file, which imports
[cljs.spec.alpha :as s]
[expound.alpha :as expound]
[devtools.core :as devtools]))
And my core.cljs file imported [reitit.coercion.spec :as reitit-spec]
, which seem to also be a culprit.
My guess right now is that I am incorrectly using /dev/ vs /prod/, and then will learn more about what reitit-spec is about.Right now, the way it is set up, I have a custom file in /env/dev/cljs/[app-name]/app.cljs
, which does the following:
(ns ^:dev/once
(:require
[virtual-library.core :as core]
[cljs.spec.alpha :as s]
[expound.alpha :as expound]
[devtools.core :as devtools]))
(extend-protocol IPrintWithWriter
js/Symbol
(-pr-writer [sym writer _]
(-write writer (str "\"" (.toString sym) "\""))))
(set! s/*explain-out* expound/printer)
(enable-console-print!)
(devtools/install!)
(core/init!)
Looking at project.clj, looks like this gets replaced by a /prod/
in uberjar:
{:uberjar {:omit-source true
:prep-tasks ["compile" ["shadow" "release" "app"]]
:aot :all
:uberjar-name "virtual-library.jar"
:source-paths ["env/prod/clj" "env/prod/cljs" ]
:resource-paths ["env/prod/resources"]}
I think the way I set up shadow, the reporting script is assuming env/dev/*. Will look deeper into this, and :preloads
.
From a quick test, looks like this is indeed what is happening,in your build config set :modules {:app {:init-fn
Also, with reitit-spec removed, and the dev/app stuff, now we’re muuch better: (will update with your advice and keep playing with the optimization)
Okay, current shadow setup:
{:nrepl {:port 7002}
:builds
{:app
{:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:init-fn virtual-library.core/init! :preloads [virtual-library.dev]}}
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
:devtools {:preloads [day8.re-frame-10x.preload]
:watch-dir "resources/public"}}
:test
{:target :node-test
:output-to "target/test/test.js"
:autorun true}}}
first thought, will try moving day8.re-frame-10x.preload
into virtual-library.dev
. Let me know if there’s more cleanup I could do : } — thanks team