Fork me on GitHub
#shadow-cljs
<
2019-08-25
>
sif01:08:41

I’m trying to move @thheller fulcro expo example from F2 to F3 (current one) after but I’m getting

Module app registry is not registered call-back module
, the code in question is:
(defonce app (app/fulcro-app
               {:render-root! expo/render-root}))

(defn  init
       {:dev/after-load true}
      []
      (app/mount! app Root :i-got-no-dom-node)
      (js/console.log "Loaded"))

 
` Where app comes from [com.fulcrologic.fulcro.application :as app] Any ideas?

zebu07:08:32

I'm just trying shadow-cljs for the first time, I'm getting an error when I include reagent in the shadow-cljs dependencies

zebu07:08:42

The required namespace "react" is not available, it was required by "reagent/core.cljs".
The namespace was provided via :foreign-libs which is not supported.
Please refer to  for more information.
You may just need to run:
  npm install react

zebu07:08:01

I have done npm install react etc

zebu07:08:25

npm install react react-dom create-react-class

thheller07:08:35

make sure you did that in the correct directory

thheller07:08:49

there should be a <project>/node_modules/react/package.json for example

zebu07:08:58

I don't have the node_modules folder there

thheller07:08:18

do you have a package.json in your project dir?

thheller07:08:33

otherwise run npm init -y in your project dir first

thheller07:08:49

what did you use to start the project?

zebu07:08:19

it is an old project, can't quite remember, some lein template

thheller07:08:03

yeah that likely won't have a package.json so you should create that via npm init -y

zebu07:08:42

that worked

zebu07:08:21

npm init -y

zebu07:08:26

and then

zebu07:08:37

npm install react react-dom create-react-class

zebu07:08:50

thanks 🙂

👍 4
thedavidmeister09:08:31

i am struggling to see how :npm-deps works

thedavidmeister09:08:49

i put it in both my deps.edn and a deps.cljs file in src somewhere

thedavidmeister10:08:15

it just complains with "you probably need to run: npm install auth0-js"

thedavidmeister10:08:31

wait... i got it

thedavidmeister10:08:01

"at the root of the classpath"

thedavidmeister10:08:09

those words missing from the docs

thheller10:08:08

that is only for publishing libraries

thheller10:08:29

your JS dependencies are managed via package.json

thheller10:08:55

it is assumed that you use npm install react or so to manage JS deps (which will add it to package.json)

thedavidmeister10:08:34

i just put deps.cljs at the top of my classpath and shadow cljs did an npm save

thedavidmeister10:08:57

which... yes... put it in package.json

thedavidmeister10:08:00

so what's that all about?

thheller10:08:06

npm uses package.json so we need to put it there. I only recommend using deps.cljs when publishing libraries. Otherwise use package.json directly AND keep your package-lock.json in version control too.

thedavidmeister10:08:02

publishing where?

thedavidmeister10:08:06

what is a library in your mind?

thheller10:08:17

[reagent "0.8.1"]

thheller10:08:50

anything you use as a dependency. not your actual project for a SPA or whatever

thheller10:08:17

published to clojars or any other maven repo

thedavidmeister10:08:52

this is a library published to clojars and used downstream by an SPA

thedavidmeister10:08:32

and i have a demo site in the repo that is an SPA on github pages

thheller10:08:46

the SPA should manage its dependencies via package.json

thedavidmeister10:08:01

should i also have a deps.cljs?

thheller10:08:24

deps.cljs does nothing except transfer the dependencies to package.json

thedavidmeister10:08:51

are you talking about the downstream SPA or the github pages demo SPA in the library repo?

thheller10:08:16

that doesn't matter really. you are making this more complicated then it is

thedavidmeister10:08:46

what does the deps.cljs do?

thheller10:08:48

if you publish a library the deps.cljs should be provided as a convenience so downstream users have that dependency automatically installed

thheller10:08:05

everything you are actually building yourself SHOULD use package.json

thedavidmeister10:08:07

well i do need to do that

thedavidmeister10:08:19

because this is a library i am publishing

thedavidmeister10:08:30

and there is a dependency on an npm package

thheller10:08:51

yes that is fine. you can have both but package.json is the source of truth and will be used over deps.cljs

thedavidmeister10:08:01

ok good to know thanks

thheller10:08:08

deps.cljs npm-deps are only only transfered if they are not contained in package.json already

thedavidmeister10:08:22

right, that makes sense

thedavidmeister10:08:32

i did ["auth0-js" :as auth0-js] in my :require

thedavidmeister10:08:51

Use of undeclared Var hoplon-auth0.api/auth0-js

thheller10:08:08

how did you use it?

thheller10:08:42

helps a lot if you show the actual full warning 😉

thedavidmeister10:08:02

------ WARNING #1 - :undeclared-var --------------------------------------------
 File: /home/thedavidmeister/hoplon-auth0/src/hoplon_auth0/api.cljs:28:2
--------------------------------------------------------------------------------
  25 | 
  26 | (defn web-auth
  27 |  []
  28 |  (auth0-js.WebAuth.
--------^-----------------------------------------------------------------------
 Use of undeclared Var hoplon-auth0.api/auth0-js
--------------------------------------------------------------------------------
  29 |   hoplon-auth0.data/web-auth))
  30 | 
  31 | (defn authorize
  32 |  ([] (authorize nil))
--------------------------------------------------------------------------------

thheller10:08:28

yeah its a namespace alias so it should be (auth0-js/WebAuth.)

thedavidmeister10:08:26

i knew it would be something dumb like that

warnsberg21:08:18

Hi! Is it possible to use git dependencies in shadow-cljs.edn?

warnsberg21:08:34

Can’t seem to find anything in the user guide and the deps.edn syntax doesn’t seem to be working

warnsberg21:08:46

(I’m trying to experiment with https://github.com/roman01la/uix specifically)

sogaiu23:08:45

@warnsberg perhaps not exactly what you are asking for, but if you don't mind using :deps true in shadow-cljs.edn + supply a deps.edn, may be that's one way?

warnsberg04:08:40

That sounds like a fine solution to me! I'll try that, thanks 🙏