This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-29
Channels
- # beginners (10)
- # cider (10)
- # cljs-dev (17)
- # clojure (14)
- # clojure-losangeles (1)
- # clojure-spec (1)
- # clojure-uk (3)
- # clojurescript (49)
- # core-async (5)
- # css (1)
- # datomic (2)
- # duct (26)
- # emacs (13)
- # figwheel (6)
- # figwheel-main (5)
- # garden (1)
- # keechma (6)
- # nrepl (1)
- # off-topic (6)
- # re-frame (52)
- # shadow-cljs (132)
- # spacemacs (4)
- # tools-deps (26)
Hi there, I am using shadow-cljs
with keechma
. Hot-reload on the keechma
project works with figwheel
but does not work with shadow-cljs
.
A sample project can be found here: https://github.com/mjmeintjes/shadow-cljs-keechma-node?files=1
How a keechma
project is structured is usually this: core.cljs
-> app/definition
-> ui/ui
-> component
In figwheel
when the component is modified the dependency graph is resolved correctly, and app/definition
is reloaded. In shadow-cljs
, the reloading propogates from component
and stops at ui/ui
The browser console output for shadow-cljs
for the code above is as follows:
shadow-cljs: call example.client.core/stop
shadow-cljs: load JS example/client/ui/main.cljs
shadow-cljs: load JS example/client/ui.cljs
shadow-cljs: load JS example/client/core.cljs
The changes did not propagate to
although it clearly has a dependency on ui/ui
:
(def definition
{:components ui
:controllers controllers
:subscriptions subscriptions
:router :history
:routes [":category/:page"]})
this will recreate the map whenever it is used. ensuring that it has all the latest references
I'd rather go with the first approach, but I didn't manage to get it to work, I'll try to replace ui
as well.
Yes, that's how keechma is structured. It's only for the component and the app-definition though. States are kept in it's own space. Feel free to ping @mihaelkonjevic
Having said that, I prefer keechma
to re-frame
it's a higher order abstraction than re-frame
and deals nicely with app states
https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/events.cljs
yeah I know but those update references in a global map on each reload and generally don't keep state from another namespace
For now we can put the keechma definitions all within a file. Just a matter of convention
since the code didn't change we only need to reload it to trigger the global state updates
Yes, I was looking for such an option. To manually specify certain namespaces to be reloaded always
The other way is to let the developer specify the namespaces that has to be reloaded. so {:reload-namspace :all}
versus {:reload-namespace [foobar.core]}
the other option is to not use those chained references from one namespace to another
the problem is when the second depends on the third because the first won't depend on the third
On dependencies in workers that depend on window: I've gone from multiple builds to splitting into multiple modules, that made them build together, but it's the :devtools :preloads fulcro.inspect.preload
that have the thing that depends on window.-localStorage
Another issue I now face is that if I want to do a
(defn ^:dev/after-load recalc []
(prim/transact!
(:reconciler @app)
`[(gsv.api.mutations/update-some-data {})]))
I don't have a ref to the state in the worker.The namespace that starts the worker doesn't get re-evalled when just the worker changes.
then you must create an after-load fn in the main app that notifies the worker to recalc (eg. send a message to it)
it has been a while since I used the worker stuff myself. I think there are still a few rough edges that could be tweaked
Yeah for now I've just been loading many workers and reloading the namespace that starts them, not caring about cleaning them up.
So I see the shadow-cljs logo when the worker compilation happened. But I can't seem to find a hook into it from the config. These don't seem to work. https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks
So now I have to change the worker, and the file that requires it. No biggie, but would be nice if changing the worker triggered the reload on namespace that requires the worker.
(defn ^:dev/after-load restart-workers [] (.terminate the-worker) (start-the-worker))
Yes, changing the worker file, saving, triggers a recompilation. But neither the :after-load from :devtools nor the annotated function from the namespace that requires the worker gets called.
Yes, that could be it. The
shadow-cljs: call gsv.client/start
browser.cljs:25 shadow-cljs: call gsv.client/recalc
util.cljs:187 Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
Don't happen when I change the worker code.the browser main doesn't have the worker code loaded (obviously) so it decides that it doesn't need to reload any code
Anyway it's not a big deal to just change both files so don't worry about solving it quickly or so.
you could annotate some namespace with :dev/always
so that some file of the main thread always gets reloaded
so nobody depends on that ns but it always gets reloaded to trigger the lifecycle fns
I need to review some of the webworker stuff to figure out how to deal with this properly
Has anybody gotten the latest posh working with shadow-cljs?
-- Syntax error -------------------
(... ... ... (... [posh.plugin-base :as base :include-macros] ... ... ...))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has extra input
------ ERROR -------------------------------------------------------------------
File: jar:file:/tank/ranmason/.m2/repository/posh/posh/0.5.6/posh-0.5.6.jar!/posh/reagent.cljs:1:1
--------------------------------------------------------------------------------
1 | (ns posh.reagent
-------^------------------------------------------------------------------------
Invalid namespace declaration
-- Spec failed --------------------
(... ... ... (:require ... ... ... ...))
^^^^^^^^
should be one of: :import, :import-macros, :refer-clojure, :require-macros, :use, :use-macros
shadow-cljs validates more strictly than the default so the default just sort of works accidentally
should be :include-macros true
or better yet a :require-macros
in the posh.plugin-base
itself
That was it.