Fork me on GitHub
#shadow-cljs
<
2021-08-17
>
nonrecursive01:08:37

hey y'all, i'm running into a strange issue. I'm using reagent and re-frame, and I have a component from namespace.a that includes a component from namespace.b. However, namespace.b/component is returning nil , which is very strange. namespace.b is requiring D3 with (:require ["d3" :as d3]) . D3 has been added to my package.json

nonrecursive01:08:48

if I take out the d3 require, then everything loads fine

nonrecursive01:08:09

Also, this is only when the app initially loads. If I make a change and shadow reloads the page, then the namespace.b/component no longer evals to nil, and everything works ok

nonrecursive02:08:39

OK it looks like upgrading from shadow-cljs 2.8.something to 2.15.3 solved the problem 🎉

thheller05:08:42

@nonrecursive always check the browser console. if the namespace fails to load for some reason it won't be available properly. browser console should tell you something at least

Quentin Le Guennec09:08:24

Hello, I have an issue with importing of a npm module in a cljc file in shadow-cljs:

------ ERROR -------------------------------------------------------------------
 File: /home/void/wp/crispeta/src/acme/web/ui/components.cljs
failed to require macro-ns "acme.web.utils.macros", it was required by "acme.web.ui.components"
Syntax error macroexpanding clojure.core/ns.
Call to clojure.core/ns did not conform to spec.
-- Syntax error -------------------

  (... (:require
        [camel-snake-kebab.core :as csk]
        ["semantic-ui-react" :as semantic-ui]))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

has extra input

-- Relevant specs -------

:clojure.core.specs.alpha/ns-form:
  (clojure.spec.alpha/cat
   :ns-name
   clojure.core/simple-symbol?
   :docstring
   (clojure.spec.alpha/? clojure.core/string?)
   :attr-map
   (clojure.spec.alpha/? clojure.core/map?)
   :ns-clauses
   :clojure.core.specs.alpha/ns-clauses)

-------------------------
Detected 1 error

thheller09:08:24

you can't do the string require in clojure

Quentin Le Guennec09:08:49

So no macros using npm modules?

thheller09:08:04

don't know what you mean by that

thheller09:08:15

a macro runs in clojure so you cannot use them in the macro directly

thheller09:08:31

you can however have the macro emit code that uses the npm module at runtime

thheller09:08:39

don't know what your intent is

Quentin Le Guennec09:08:45

I think that'll work, yes