This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-31
Channels
- # announcements (6)
- # babashka (32)
- # beginners (78)
- # biff (11)
- # calva (7)
- # clj-kondo (20)
- # clojure (35)
- # clojure-europe (10)
- # clojure-nl (4)
- # clojure-norway (8)
- # clojure-uk (2)
- # clojurescript (41)
- # conjure (14)
- # core-async (10)
- # cursive (7)
- # datomic (12)
- # deps-new (4)
- # emacs (15)
- # fulcro (48)
- # gratitude (11)
- # hugsql (1)
- # hyperfiddle (3)
- # introduce-yourself (3)
- # jobs (3)
- # klipse (2)
- # off-topic (7)
- # polylith (30)
- # reitit (1)
- # remote-jobs (1)
- # reveal (8)
- # scittle (4)
- # shadow-cljs (40)
- # squint (13)
- # tools-deps (7)
- # xtdb (7)
How viable is it to use shadow's clojure APIs directly as opposed to using npx shadow-cljs
? Does the NodeJS API do a lot of magic (middleware, etc.) in addition to calling (server/start!)
?
What's the minimum Clojure code to replicate the exact behavior of npx shadow-cljs server
?
@zhuxun2 https://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html
to get the exact behavious of server
you just have (server/start!)
. thats all as far as the shadow-cljs build server is concerned
however the "connect to server" part of the node shadow-cljs
command cannot really be replicated
so you probably want to do all other stuff over the REPL or UI and now use further CLI command to start a watch for example
Hello, @thheller.
Could you help me, please. I’m working on migrating from figwheel-main
to shadow-cljs
and unfortunately I can’t change the structure of the project.
I have a backend
module that serves my static files via /static
route, and I have a frontend
module that compiles js to the backend resource directory backend/resources/public/frontend2/assets/js
. I don’t have a file index.html
- the server generates it itself.
JS files are reloaded correctly, but I have some problems with reloading resources (CSS). Any changes to CSS files are not handled.
I have a webpack
configuration that compiles less
files to the backend resources directory /backend/resources/public/frontend2/assets/bundle.css
I added the parameters :watch-dir
and :watch-path
, but it didn’t help.
[:link {:rel "stylesheet", :href "static/frontend2/assets/bundle.css", :type "text/css"}]
[:script {:src "static/frontend2/assets/js/app.js", :type "text/javascript"}]
:app {:target :browser
:output-dir "../backend/resources/public/frontend2/assets/js"
:asset-path "static/frontend2/assets/js"
:modules {:app {:init-fn frontend.core/-main}}
:devtools {:preloads [devtools.preload]
:watch-dir "../backend/resources/public/frontend2/assets"
:watch-path "static/frontend2"}
Thank you!@just.sultanov what is the path you include to css in the html?
https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html might help
I'm guessing its :watch-dir "../backend/resources/public"
but can't say exactly without known the paths
(meaning why is the path in that html relative? what is the path of the page you are calling?)
[:link {:rel "stylesheet", :href "/static/frontend2/assets/bundle.css", :type "text/css"}]
?
Backend generates the following paths:
[:link {:rel "stylesheet", :href "static/frontend2/assets/bundle.css", :type "text/css"}]
[:script {:src "static/frontend2/assets/js/app.js", :type "text/javascript"}]
then its :watch-dir "../backend/resources/public/frontend2"
and :watch-path "static/frontend2"
Yes, the path to static files is relative. This is provided by the compojure context. Well, thank you. I will try to use absolute paths
thats fine, just makes it harder to answer the question without knowing the full exact paths 😉
Hi, new to shadow-cljs and CLJS in general. I've tried out both figwheel-main and shadow-cljs in some learning projects with basic configurations, and I've noticed that when using figwheel, I can get completions for goog.dom functions in a CIDER REPL by simply typing "goog.dom/...", while I don't get auto-completion in shadow-cljs builds for vars in that namespace. Is this related to this issue https://github.com/thheller/shadow-cljs/issues/834 ?
is there an alternative to nuking .shadow-cljs
when a https://github.com/babashka/sci/blob/133a7565749ac6cd5a8308182f0b1c7fc47e8a3d/src/sci/impl/namespaces.cljc#L53-L64 depending on the contents of an env var? Maybe a way to whitelist env vars that shadow can take into account for caching?
what I do in one of my projects is https://github.com/clavascript/clavascript/blob/a5a63bf19025f8535a5a3f3f4ef8c1dde2d4786c/bb/tasks.clj#L61
could store it there and get it out of the (get-in @cljs.env/*compiler* [:options :external-config :whatever-you-added])
during compilation
shadow does a lot better in cache invalidation regarding macros than the regular cljs compiler, correct? But reading from the env will fail bust its caching strategy?
ok, have you considered being able to signal (maybe via metadata) on a macro var that it should not be cached or does that not make sense?
well to know if it can use the cache it must be able to derive it from only the file and compare before compilation
I guess there could be some way for a macro to signal "hey, please don't cache this file"
@mkvlr have you considered the :cache-blockers config here? https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache
also :dev/always iiuc https://shadow-cljs.github.io/docs/UsersGuide.html#_metadata @mkvlr