Fork me on GitHub
#shadow-cljs
<
2020-01-06
>
postma.marin00:01:06

I am using the reagent shadow-cljs template, but when building for release, the app is not mounted (the content of http://div.app is not replaced with the app content). In order to make it easier to debug, I have tried with the template alone, just building it to see if i had made a mistake somewhere, but I get the same result... So i guess there is someething wrong with the template... Is there anything wrong with my shadow-cljs.edn ?

{:lein         true
 :source-paths ["src"]
 :builds       {:app {:target     :browser
                      :output-dir "resources/public/js"
                      :asset-path "/js"
                      :modules    {:app {:entries [psw.core]}}
                      :devtools   {:after-load psw.core/mount-root}}}
 :dev-http     {3000 {:root    "resources/public"
                      :handler psw.handler/app}}}
I ran npx shadow-cljs release app please excuse my noobness :)

postma.marin00:01:27

Also I get no message whathowever from the console, so I have no idea where to look

royalaid05:01:16

@thheller usability question. I have a bunch of AWS javascript lambda's that are using shadow and each one runs its own repl with it's own dependencies. Is there a good clean way to work like this? I feel like I need to build something to manage all the REPLs.

thheller09:01:42

@postma.marin where is your init! fn called? assuming from your HTML somewhere?

thheller09:01:53

@royalaid work like this with what?

postma.marin10:01:59

@thheller you mean I should do something like :modules {:app {:entries [ydfg.core/init!]}}, ? because it causes that:

[markdown-to-hiccup "0.6.2"]
Invalid configuration
-- Spec failed --------------------

  {:target ...,
   :output-dir ...,
   :asset-path ...,
   :modules {:app {:entries [ydfg.core/init!]}},
                             ^^^^^^^^^^^^^^^
   :devtools ...,
   :build-id ...}

should satisfy

  unquoted-simple-symbol?

or

  string?

postma.marin10:01:42

my html is just this:


<html>
  <head>
    <meta charset="utf-8">
    <title>Example</title>
    <link rel="stylesheet" href="css/site.css">
  </head>
  <body>
    <div id="app">
      <h1>Hello world</h1>
    </div>
    <script src="/js/app.js"></script>
  </body>
</html>

thheller10:01:43

no. in your current setup you have a init! fn in psw.core

thheller10:01:09

are you sure psw.handler/app emits that html?

thheller10:01:45

sure you can change your config to call the init-fn ... but first you should figure out why it is different from dev/release in the first place

thheller10:01:52

understand your setup first ... then adjust it

thheller10:01:29

something appears to be calling the init! if it works in dev mode?

thheller10:01:54

or does it not work at all? judging from your "when building for release" I assumed it works in dev

postma.marin10:01:03

well there is a weird behaviour in dev mode, where I have to specify a route other than "/" the first time it is lauched for it to start, but I read that it might just be a server config issue + this trick don't work in release

thheller10:01:51

so you likely just want :modules {:app {:init-fn psw.core/init!}} in your config

postma.marin10:01:19

if a do that it causes this compile error

Invalid configuration
-- Spec failed --------------------
  {:target ...,
   :output-dir ...,
   :asset-path ...,
   :modules {:app {:entries [ydfg.core/init!]}},
                             ^^^^^^^^^^^^^^^
   :devtools ...,
   :build-id ...}
should satisfy
  unquoted-simple-symbol?
or
  string?

thheller10:01:35

you didn't do what I pasted

postma.marin10:01:06

oh yes, my bad

postma.marin10:01:22

@thheller thank you very much! it works :+1: have a nice day ūüôā

vitek.kalisz14:01:09

I am trying wrap TextField a Material-UI component to use in my project called Orgpad. I have this minimal project here: https://github.com/vitkalisz/shadow-cljs-materialui.git where everything works just fine. However when doing the same in Orgpad, I get some ?dependency problem? screenshotted below, which persists even after I reduce the project to a minimal version similar to that in the example. (I am just rendering a TextField , I have commented out every other namespace - leaving just the one rendering the TextField, I have reduced shadow-cljs.edn to this:

{:source-paths ["src"]
 :dependencies [[reagent "0.9.0-rc4"]]
 :nrepl        {:port 9000}
 :builds       {:client {:target           :browser
                         :output-dir       "resources/public/js/compiled"
                         :asset-path       "/js/compiled"
                         :modules          {:main {:init-fn orgpad.client.core/init}}
                         :compiler-options {:infer-externs :auto}
                         :devtools         {:after-load orgpad.client.core/mount-root
                                            :watch-dir  "resources/public"}}}}
dependencies in package.json to this:
"dependencies": {
    "@material-ui/core": "^4.8.0",
    "create-react-class": "^15.6.3",
    "react": "^16.12.0",
    "react-dom": "^16.12.0"
  }
I ran npm install, npm clean-install and restarted shadow-cljs) Would somebody please help me figure out why there is this problem?

thheller14:01:44

@vitek.kalisz and the code? it appears that you are doing something like [foo] where foo is nil

thheller14:01:55

the error you posted is not from the code you posted? (the code you posted compiles and runs fine for me)

adambergman15:01:20

Hi!¬† I would be much helpful if anyone could point me in the right direction with this :)¬† I have made an new project with ‚Äúlein new luminus adambergmanio +jetty +h2 +re-frame +reitit +shadow-cljs‚ÄĚ When I try to run ‚Äúlein uberjar‚ÄĚ I get this exception:

clojure
[:app] Compiling ...
IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError
    clojure.lang.Reflector.getInstanceField (Reflector.java:397)
    clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440)
    shadow.build.closure/js-error-xf/fn--11573 (closure.clj:536)
    clojure.core/map/fn--5862/fn--5863 (core.clj:2742)
    clojure.core.protocols/iter-reduce (protocols.clj:49)
    clojure.core.protocols/fn--8140 (protocols.clj:75)
    clojure.core.protocols/fn--8140 (protocols.clj:75)
    clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
    clojure.core/transduce (core.clj:6884)
    clojure.core/into (core.clj:6899)
    clojure.core/into (core.clj:6887)
    shadow.build.closure/log-warnings (closure.clj:1081)
    shadow.build.closure/log-warnings (closure.clj:1077)
    shadow.build.closure/log-warnings (closure.clj:1079)
    shadow.build.closure/log-warnings (closure.clj:1077)
    shadow.build.closure/optimize/fn--11790 (closure.clj:1185)
    shadow.build.closure/optimize (closure.clj:1170)
    shadow.build.closure/optimize (closure.clj:1161)
    shadow.build.api/optimize (api.clj:268)
    shadow.build.api/optimize (api.clj:262)
    shadow.build/optimize (build.clj:411)
    shadow.build/optimize (build.clj:403)
    shadow.cljs.devtools.api/release* (api.clj:350)
    shadow.cljs.devtools.api/release* (api.clj:336)
    shadow.cljs.devtools.cli/do-build-command (cli.clj:29)
    shadow.cljs.devtools.cli/do-build-command (cli.clj:26)
    shadow.cljs.devtools.cli/do-build-commands (cli.clj:51)
    shadow.cljs.devtools.cli/do-build-commands (cli.clj:40)
    shadow.cljs.devtools.cli/main/body-fn--16106--auto----16696 (cli.clj:168)
    shadow.cljs.devtools.cli/main (cli.clj:167)
    shadow.cljs.devtools.cli/main (cli.clj:134)
    clojure.core/apply (core.clj:669)
    clojure.core/apply (core.clj:660)
    shadow.cljs.devtools.cli/-main (cli.clj:221)
    shadow.cljs.devtools.cli/-main (cli.clj:219)
    clojure.lang.Var.invoke (Var.java:388)
    user/eval140 (form-init5608872905668697635.clj:1)
    user/eval140 (form-init5608872905668697635.clj:1)
    clojure.lang.Compiler.eval (Compiler.java:7177)
    clojure.lang.Compiler.eval (Compiler.java:7167)
    clojure.lang.Compiler.load (Compiler.java:7636)
    clojure.lang.Compiler.loadFile (Compiler.java:7574)
    clojure.main/load-script (main.clj:475)
    clojure.main/init-opt (main.clj:477)
    clojure.main/init-opt (main.clj:477)
    clojure.main/initialize (main.clj:508)
    clojure.main/null-opt (main.clj:542)
    clojure.main/null-opt (main.clj:539)
    clojure.main/main (main.clj:664)
    clojure.main/main (main.clj:616)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.main.main (main.java:40)
```

thheller15:01:58

@adambergman that is caused by a dependency conflict on the closure-compiler version

thheller15:01:29

shadow-cljs expects these versions but you seem to be ending up with different ones

thheller15:01:34

[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]

thheller15:01:04

(happens when you use deps.edn or project.clj and include conflicting dependencies)

adambergman15:01:43

@thheller ah ok! thank you very for instant reply! (and for the work you are putting into shadow-cljs ^^)

adambergman16:01:22

Hi again, sorry but I still have trouble fixing it. It seems that re-frame and reagent was the conflicting dependencies. At first I got this message: NPM dependency ‚Äúreact‚ÄĚ has installed version ‚Äú16.8.6" ‚Äú16.9.0‚ÄĚ was required by jar:file:/Users/adambergman/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs NPM dependency ‚Äúreact-dom‚ÄĚ has installed version ‚Äú16.8.6‚ÄĚ ‚Äú16.9.0" was required by jar:file:/Users/adambergman/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs [:app] Compiling ... IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError then I checked which reagent version (16.9.0) that was used in the latest re-frame version (0.11.0-rc3) and changed the re-frame to this version. Then I changed react and react-dom versions to ‚Äú16.9.0‚ÄĚ. When I run ‚Äúlein uberjar‚ÄĚ again after this I still get ‚ÄúIllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError‚ÄĚ but it is not complaing on different versions or anything like that.¬† Is there some way to create a new luminus project that¬†works out of the box? Like using some version that is confirmed to work ¬† Sorry for the inconvenience, I am new to clojure(script) and just trying to get get something running :D

adambergman16:01:47

I meant to say that I changed re-frame version to latest version and also changed reagent version to the version that was stated in re-frames deps.clj

thheller16:01:40

reagent and re-frame have nothing to do with this

thheller16:01:50

it is striclty and incompatile closure-compiler version

thheller16:01:31

one of the reasons I recommend running shadow-cljs standalone (no deps.edn/project.clj) so you don't have to deal with this crap

thheller16:01:23

you can just add the dependencies I pasted above to you project.clj :dependencies list

adambergman16:01:42

oh ok I have no idea what I am doing ūüôā ok I just tried to get an ‚Äútemplate‚ÄĚ app up and running using luminus.

adambergman16:01:10

by running standalone how would I compile it

adambergman16:01:50

thanks again i will try!

thheller16:01:03

maybe the luminus template is a bit out of date. I don't know any of the details there

adambergman16:01:19

so i should use shadow-cljs separeate

thheller16:01:39

you can use lein ... that is totally fine ... BUT then you have to sort out these kind of dependency conflicts

thheller16:01:59

if you use shadow-cljs.edn the tool sorts those out for you for the most part

thheller16:01:20

you can run lein deps :tree and resolve the conflicts

thheller16:01:37

by either adding the :exclusions or adding the proper versions of the dependencies I pasted above

adambergman16:01:08

i will try with these dependencies first,

adambergman17:01:45

it worked fine with the dependencies you provided ūüôā !