This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-06
Channels
- # announcements (3)
- # babashka (1)
- # beginners (26)
- # calva (1)
- # cider (17)
- # clj-commons (16)
- # clj-kondo (11)
- # clojure (21)
- # clojure-europe (9)
- # clojure-norway (1)
- # clojure-portugal (2)
- # clojure-spec (8)
- # clojure-uk (4)
- # clojurescript (35)
- # datomic (5)
- # emacs (9)
- # figwheel-main (15)
- # fulcro (26)
- # honeysql (1)
- # lsp (5)
- # off-topic (2)
- # polylith (1)
- # rdf (6)
- # re-frame (4)
- # reagent (15)
- # reitit (9)
- # releases (2)
- # shadow-cljs (4)
- # sql (25)
- # squint (2)
- # xtdb (7)
Is there a restriction on using namespace app
? I was trying to make a very minimal example and my :init-fn
is app/init
and I get errors stating “Error: Namespace ‘app’ already declared” and “An error occurred when calling (app/init)” “TypeError: app.init is not a function”. That’s on the first load of the page. If I save a file in the project, shadow recompiles and reloads the browser and I don’t get the errors. But on a fresh reload I get the errors back again. If I change my namespace to something else, like myapp
, no errors. If I move the file down into a subdirectory, so the namespace is
, no errors. But I can’t seem to use just plain app
directly under my ‘src’ directory as my main entry point.
should be fine, but be aware that it easily clashes with other variables you might have in your JS. maybe you have a app
variable like var app
or
from somewhere else?
but there was another issue with single segment namespaces. maybe thats related somehow, didn't look into it yet. https://github.com/thheller/shadow-cljs/issues/1059
I did some more testing and it turns out I can’t use the same name for both (1) the namespace hosting the module’s :init-fn and (2) the id of the DOM element that reagent will render into. I’m not expert enough to understand why that is the case, but I’ve isolated the collision to those two places.