shadow-cljs 2020-01-06

@postma.marin has joined the channel

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 :)

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

@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.

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

@royalaid work like this with what?

@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?

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>

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

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

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

understand your setup first ... then adjust it

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

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

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

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

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?

you didn't do what I pasted

oh yes, my bad

@thheller thank you very much! it works 👍 have a nice day 🙂

👍 1

@ban.istvan has joined the channel

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?

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

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

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)
```

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

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

[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"]

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

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

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

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

reagent and re-frame have nothing to do with this

it is striclty and incompatile closure-compiler version

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

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

oh ok I have no idea what I am doing 🙂 ok I just tried to get an “template” app up and running using luminus.

by running standalone how would I compile it

thanks again i will try!

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

so i should use shadow-cljs separeate

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

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

you can run lein deps :tree and resolve the conflicts

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

i will try with these dependencies first,

it worked fine with the dependencies you provided 🙂 !

👍 1