Fork me on GitHub
#shadow-cljs
<
2022-11-06
>
wevrem04:11:27

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.

thheller05:11:16

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?

thheller05:11:19

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

wevrem15:11:50

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.