This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-04
Channels
- # announcements (1)
- # babashka (41)
- # beginners (124)
- # cider (8)
- # clj-kondo (25)
- # cljs-dev (40)
- # clojars (4)
- # clojure (92)
- # clojure-europe (35)
- # clojure-italy (3)
- # clojure-nl (4)
- # clojure-uk (91)
- # clojuredesign-podcast (8)
- # clojurescript (41)
- # code-reviews (1)
- # cursive (11)
- # data-science (1)
- # datascript (76)
- # datomic (45)
- # emacs (4)
- # etaoin (3)
- # events (1)
- # figwheel-main (2)
- # fulcro (9)
- # graalvm (1)
- # jackdaw (6)
- # jobs (1)
- # jobs-discuss (3)
- # kaocha (4)
- # malli (25)
- # off-topic (42)
- # pathom (4)
- # reitit (11)
- # releases (2)
- # reveal (1)
- # shadow-cljs (53)
- # sql (4)
- # tools-deps (190)
- # vrac (19)
- # xtdb (6)
When I want to hack on my node app, I first start up Shadow in watch
mode. Then I need to wait a bit until Shadow is done compiling, before starting the node process. Can I automate this in some way?
@grav you can try something like this:
srv=build/server.js
# run the server under node
( rm -f ${srv}; while [ 1 ]; do if [ -f ${srv} ]; then node ${srv}; else sleep 1; fi; done ) &
# watch-and-compile the server
( npx shadow-cljs watch server ) &
here the node script artifact being built is build/server.js
Ah, good idea. So simply remove the build artifact and then wait for it to show up!
at the end of the script i have a wait
and run everything as background tasks. at the start of the script i have this:
trap killgroup SIGINT
killgroup(){
echo killing...
kill 0
}
which kills everything launched in the script when ctrl-C is runprobably i should document this somewhere
@thheller So you mean use Clojure instead of Bash? Sounds tempting :-)
I haven't used the shadow api much, apart from (shadow/watch :my-app)
. But that doesn't seem to work in a node-repl? Am I mis-reading https://shadow-cljs.github.io/docs/UsersGuide.html#node-repl?
you just get a blank CLJS REPL that isn't tied to your :my-app
build but can still just (require '[
and (x/main "foo" "bar")
or so (emulating a regular :node-script
build for example)
node-repl
just manages the node process so you don't have to use hacks to wait for files to appear or so
now getting TypeError: ia.format is not a function in release, but works in repl. Obviously getting minified away. Any good way to avoid?
@hoppy you were probably relying on some of your :preloads
loading goog.string.format
you need to because goog.string
and goog.string.format
format are basically 2 namespaces
you are probably right though, I dug that code out of a different working project, so it was probably osmosis of some sort.
yeah it works by accident if goog.string.format
was required anywhere else but its not something you should rely on so the :require
fixes that
Hello! When I make a simple change to my app, it takes Shadow 3-7 seconds to recompile the change, after which the app re-renders. Is that duration normal? Or do I use too many libraries or is the changed UI namespace too large? What can I do to speed it up, so that I can change the code (add a new dom element, change button label, ...) and see the change "at once"? Thank you!!!
IME keeping files small makes a good difference for compilation times, so it potentially has less things to compile
3-7 seconds seems a very high time for me, in the biggest project I worked on (30k+ LOC), we were still getting compilations in 500ms avg (except when touching some of the big files, there it could go up to 3 seconds, but rarely more than that)
Thanks! Perhaps something is wrong with my setup, I will clean up everything and upgrade shadow to latest.
@holyjak that seems excessive and shouldn't be that slow. complex macros can significantly impact recompile speeds. maybe try running with shadow-cljs watch app --verbose
or use the UI to see where it spends its time
Here is the verbose log:
[:main] Compiling ...
<- Resolving Module: :main (171 ms)
<- Compile CLJS: minbedrift/ui.cljc (118 ms)
<- Compile CLJS: minbedrift/ui/kostnadsdeling/ui.cljc (1460 ms)
<- Cache write: minbedrift/ui.cljc (852 ms)
<- Cache write: minbedrift/ui/kostnadsdeling/ui.cljc (1370 ms)
<- build target: :browser stage: :compile-finish (312 ms)
<- Flushing unoptimized modules (2066 ms)
<- build target: :browser stage: :flush (2465 ms)
[:main] Build completed. (1076 files, 2 compiled, 0 warnings, 6.64s)
I think I saw much better compile times on this app before summer so something in the environment must have changed...well thats defienitely slow. what does minbedrift/ui/kostnadsdeling/ui.cljc
do? macro heavy stuff? maybe including huge edn data?
No. no big EDN. kostnadsdeling/ui
has 593 lines, 31KB, and 13 direct macro calls, namely Fulcro's defsc
.
minbedrift/ui
has 3KB and 75 lines (and includes the kostnadsdeling.ui namespace and others).
After really upgrading to 2.11.1 I get
<- Cache write: minbedrift/ui.cljc (709 ms)
<- Compile CLJS: minbedrift/ui/kostnadsdeling/ui.cljc (1339 ms)
<- Cache write: minbedrift/ui/kostnadsdeling/ui.cljc (552 ms)
after a trivial code changesource file size doesn't necessarily mean much if there is a macro in it expanding to something huge
I'm not on macos but on windows the windows defender thing is causing such issues and performance goes up significantly if the project dir is just ignored
Thanks, I will try that!
I guess my shadow issues are related to the following problem logged in the browser console, which I have not seen before (on a project I haven't used for a 2-3 months): > failed to parse websocket message {:type :repl/init, :repl-state {:shadow.cljs.repl/repl-state true, :current-ns cljs.user, :repl-sources [...], :repl-actions []}} #error {:message "Invalid reader tag: :type. Reader tags must be symbols.", :data {:type :reader-exception, :ex-kind :reader-error}} Any idea what could be wrong / where to look? I have just upgraded to shadow 2.11.1, deleted node_modules and .shadow-cljs, and installed/started from scratch.
@holyjak uhm that doesn't look like 2.11.1? do you use project.clj or deps.edn and didn't upgrade there?
thank you! What about package.json? Does the version been manually synced between this and deps?