Has anyone used apollo client with shadow-cljs? Or does lack of webpack prevent that from working.
does it explicitely depend on webpack?
Are there really libs that actually do? I've seen some libs that claim to require webpack (by mentioning it as part of their install) but none of these actually did. Actually depending on it sounds like terrible design...
some are rather webpack specific yes but not that common in popular libs
Anyone using dynamic loading (shadow.loader) with or without shadow.lazy?
I do
I have a module with an init-fn that fn loads a module dynamically, but im having issues calling things from the loaded module
:module-loader true
:modules {:base {:entries [app.debug app.auth]}
:common {:entries [app.index]
:depends-on #{:base}}
:app {:init-fn app.main/init!
:depends-on #{:common}}
:cloud {:entries [app.main.cloud]
:depends-on #{:app}}}
I'm assuming this doesn't actually say :cloud {:entities
?
that could very well be a typo
I was tired lastngiht
I had that module as an init-fn as well as a test
when using it as an init-fn it loaded - but I got a whole bunch of errors that things were already declared
;; app/main.cljs
(defn init! []
(loader/with-module :cloud
(fn []
(let [cloud (resolve 'app.main.cloud/dashboard)]
(cloud)))))
failed to load clojure.set.js Error: Namespace "clojure.set" already declared.
hmm don't use with-module
?
(-> (loader/load :cloud) (.then (fn [] ...))
I can't remember what with-module
is for
also just use shadow.lazy. much better API and doesn't involve dealing with resolve
issues
Ideally I want to use shadow.lazy but It couldnt find the modules
what does that mean?
when I give it the symbol the compiler throws an error about not finding the app.main.cloud module
to the loadable
(def components
(lazy/loadable {:cloud app.main.cloud/dashboard)})
(defn init! []
(-> (lazy/load components)
(.then
(fn [{:keys [cloud]}]
(cloud)))))
well if you actually had the typo from earlier that may have been the cause?
I mean if the ns isn't actually included in the build?
So the block above does work, but I still get the same console errors
ill check the manifest again
also note that if you are loading the module directly on init it would be better to have your HTML load it immediately instead
but otherwise this looks fine
base.js:2226 failed to load goog.dom.inputtype.js Error: Namespace "goog.dom.InputType" already declared.
is the depends-on correct? should the dynamic modules “depend” on the main loader module, or the other way around?
this seems to be thrown by the dynamic module
try triggering the load via some kind of async delay
(js/setTimeout (fn [] _here_ ) 0)
or so
maybe its a race condition
ok so i reduced the number of them by removing the module from the index file
don't know what that means
<!doctype html>
<html>
<body>
<script src="./client/base.js"></script>
<script src="./client/common.js"></script>
<script src="./client/app.js"></script>
</body>
</html>
thats the index file
I had the cloud.js in there
ah yeah if you do that you definitely need the timeout
otherwise it triggers the load twice
so im still getting some of them
I don't like that you have ./client
as the path. much more predictable if you use absolute paths with the proper absolute :asset-path
as well
yeah thats an issue with the kubernetes ingress
but besides that I don't have enough information to help
it all looks fine from here
ok good to know im at least kinda understanding this 😅
doing it with the lazy block as above seems to be working now, could very well have been a typo causing the issue with it last night