This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-16
Channels
- # adventofcode (24)
- # announcements (3)
- # aws (3)
- # babashka (16)
- # beginners (88)
- # biff (5)
- # calva (27)
- # cider (15)
- # cljs-dev (70)
- # clojure (87)
- # clojure-austin (3)
- # clojure-belgium (6)
- # clojure-europe (59)
- # clojure-nl (1)
- # clojure-norway (14)
- # clojure-uk (3)
- # clojurescript (37)
- # data-science (2)
- # datalevin (40)
- # datomic (1)
- # emacs (23)
- # events (2)
- # graalvm (13)
- # graphql (7)
- # gratitude (1)
- # holy-lambda (193)
- # inf-clojure (15)
- # lsp (27)
- # malli (9)
- # off-topic (20)
- # polylith (6)
- # reitit (29)
- # releases (2)
- # scittle (13)
- # shadow-cljs (51)
- # transit (15)
- # xtdb (29)
Hi. I am playing with webworkers for the first time: I can successfully call into the webworker module, but I quickly see a console error
worker.js:1453 failed to load shadow.module.gamelogic.append.js ReferenceError: shadow is not defined
at eval (shadow.module.gamelogic.append.js:2:1)
at eval (<anonymous>)
at goog.globalEval (robot.js:497:11)
at env.evalLoad (robot.js:1451:12)
at worker.js:1506:12
worker.js is my worker module
gamelogic is a shared module that it depends upo; presumably Ihave forgotton to import something..?yes, I did
:robot {:entries [foo.robot]
:depends-on #{:gamelogic}
:web-worker true}
}
and what is this file trying to call? just look at the source in the cljs-runtime dir
could the gamelogic module be inadequate?
:gamelogic {:entries [foo.encode-board
foo.calc-moves]}
so the action line that triggers the error is on the first line of
shadow.module.gamelogic.append.js
shadow.cljs.devtools.client.env.module_loaded('gamelogic');
yes is it
it is
yes this is the first error upon a reload]
So I do have other CORS errors, because this is a dev experiment and it is trying to connect to public facing website was hoping that would not be relevant
ah okay
so I have to set things up properly adn then try again
so you (defn init [] (do-stuff))
and shadow-cljs call it, instead of just (do-stuff)
in an ns somewhere
following the init/start/stop logic as desribed in https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html
ah okay; was following the code pattern in https://github.com/thheller/shadow-cljs/issues/655
perhaps I don't understand. Am attaching event listener globally like
(js/self.addEventListener "message"
(fn [^js evt]
and you are saying that this should be done within an init
function?Interestingly, the web worker is behaving as expected; this error message is just creating console noise
I'll tidy up my stuff and then try again
thanks for the help
the error is not in the web worker; the error is in the main module
When attempting to set up module dependencies,
I set a
:default true
like this
:main {:entries [foo.main]
:init-fn foo.main/main
:depends-on #{:gamelogic}
:default true}
and clearly it does no do what I expected it to doI was originally hoping to avoid specifying dependencies but shadow-cljs told me that it could not figure out the hierarchy so I set the :default flag, and that error seemed to go away
but I got got the subsequent
gamelogic.js:1451 ReferenceError: shadow is not defined
at eval (shadow.module.gamelogic.append.js:2:1)
at eval (<anonymous>)
at goog.globalEval (gamelogic.js:497:11)
at env.evalLoad (gamelogic.js:1559:12)
at gamelogic.js:1615:12
do I have to use module dependencies?
so this is the error I get with no dependencies
[:foo] Build failure:
two modules without deps, please specify which one is the default
{:a :main, :b :robot}
ExceptionInfo: two modules without deps, please specify which one is the default
shadow.build.targets.browser/pick-default-module-from-config/fn--25576 (browser.clj:174)
if I set the problematic :default true
in the main module then I get a different error
[:foo] Build failure:
no common dependency found for src
{:src [:shadow.build.classpath/resource "goog/base.js"], :deps #{:main :robot}}
ExceptionInfo: no common dependency found for src
shadow.build.modules/compact-build-modules/find-closest-common-dependency--15601
what does that :default
flag really do?