Fork me on GitHub
#shadow-cljs
<
2018-05-09
>
odie08:05:22

Hi all, I’m just getting started with fulcro and exploring the shadow-cljs version of the app template a bit. I can connect and drop into the cljs repl. The prompt indicates I’m in the cljs.user namespace. But, if I were to create a matching “cljs/user.cljs” file, none of the code in the file seems to be loaded. Any idea what I might be doing wrong?

thheller08:05:58

@odie oh I forgot about that. it currently doesn't check the filesystem and always generates one. please open a ticket so I don't forget it again

odie08:05:16

Oh! Good thing I asked! I’ve been messing around with this for too long, thinking I must be missing something obvious. 😃 Will open a ticket!

thheller09:05:32

@odie fixed in 2.3.21. as a bonus :devtools {:repl-init-ns my.app} is now also supported

❤️ 4
odie09:05:58

Thanks! That was fast! :thumbsup:

kurt-o-sys10:05:05

I'm trying to run shadow-cljs with lein. Without lein, I have no problems. With lein:

$ shadow-cljs watch app
shadow-cljs  <project-home> 
shadow-cljs - config: <project-home>/shadow-cljs.edn version: 2.3.19
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app
Exception in thread "main" java.lang.RuntimeException: Unable to find static field: ECMASCRIPT6 in class com.google.javascript.jscomp.CompilerOptions$LanguageMode, compiling:(shadow/cljs/closure.clj:712:13)
        at clojure.lang.Compiler.analyze(Compiler.java:6792)

thheller10:05:40

@kurt-o-sys with lein you need to put clojurescript into your deps

thheller10:05:03

otherwise you probably end up with an old incompatible version

thheller10:05:22

check lein deps :tree which clojurescript version you are using (and which closure-compiler version)

thheller10:05:36

just adding [org.clojure/clojurescript "1.10.238"] should fix it

kurt-o-sys10:05:09

[org.clojure/clojurescript "1.10.238" :scope "provided"] is in the dependencies

thheller10:05:39

please check lein deps :tree if its actually used though

thheller10:05:01

and which com.google.javascript/closure-compiler-unshaded version in particular as that is causing the problem

thheller10:05:26

should be v20180319

kurt-o-sys10:05:06

$ lein deps :tree | grep clojure-compiler-unshaded
lein  ... Possibly confusing dependencies found:
[thheller/shadow-cljs "1.0.20170629"] -> [org.clojure/tools.reader "1.0.0"]
 overrides
[re-frame "0.10.5"] -> [org.clojure/clojurescript "1.9.908"] -> [org.clojure/tools.reader "1.0.5"]
 and
[com.taoensso/tempura "1.2.0"] -> [com.taoensso/encore "2.94.0"] -> [org.clojure/tools.reader "1.2.1"]
 and
[org.clojure/clojurescript "1.10.238"] -> [org.clojure/tools.reader "1.3.0-alpha3"]

Consider using these exclusions:
[re-frame "0.10.5" :exclusions [org.clojure/tools.reader]]
[com.taoensso/tempura "1.2.0" :exclusions [org.clojure/tools.reader]]
[org.clojure/clojurescript "1.10.238" :exclusions [org.clojure/tools.reader]]

[thheller/shadow-cljs "1.0.20170629"] -> [ring/ring-core "1.6.1" :exclusions [clj-time]]
 overrides
[ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"]
 and
[ring "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"]
 and
[ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-core "1.6.3"]
 and
[ring "1.6.3"] -> [ring/ring-devel "1.6.3"] -> [ring/ring-core "1.6.3"]
 and
[ring "1.6.3"] -> [ring/ring-core "1.6.3"]

Consider using these exclusions:
[ring "1.6.3" :exclusions [ring/ring-core]]

[com.rpl/specter "1.1.0"] -> [riddley "0.1.12"]
 overrides
[thheller/shadow-cljs "1.0.20170629"] -> [aleph "0.4.3"] -> [manifold "0.1.6"] -> [riddley "0.1.14"]

Consider using these exclusions:
[thheller/shadow-cljs "1.0.20170629" :exclusions [riddley]]

[thheller/shadow-cljs "1.0.20170629"] -> [ring/ring-core "1.6.1" :exclusions [clj-time]] -> [commons-fileupload "1.3.2"]
 overrides
[ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"]
 and
[ring "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"]
 and
[ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"]
 and
[ring "1.6.3"] -> [ring/ring-devel "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"]
 and
[ring "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"]

Consider using these exclusions:
[ring "1.6.3" :exclusions [commons-fileupload]]

[compojure "1.6.0" :exclusions [instaparse]] -> [ring/ring-codec "1.0.1"] -> [commons-codec "1.6"]
 overrides
[org.clojure/clojurescript "1.10.238"] -> [com.cognitect/transit-clj "0.8.300" :exclusions [org.clojure/clojure]] -> [com.cognitect/transit-java "0.8.324"] -> [commons-codec "1.10"]
 and
[thheller/shadow-cljs "1.0.20170629"] -> [com.cognitect/transit-clj "0.8.300" :exclusions [org.msgpack/msgpack]] -> [com.cognitect/transit-java "0.8.324"] -> [commons-codec "1.10"]

Consider using these exclusions:
[org.clojure/clojurescript "1.10.238" :exclusions [commons-codec]]
[thheller/shadow-cljs "1.0.20170629" :exclusions [commons-codec]]

thheller10:05:26

uhm thheller/shadow-cljs "1.0.20170629"?

thheller10:05:43

that is an ancient version 😛

thheller10:05:50

bump it to 2.3.21

kurt-o-sys10:05:13

ok, my bad... took some template from somewhere.

thheller10:05:32

how come you are using lein though?

kurt-o-sys10:05:32

well, maybe I didn't check the docs enough, I have in my project.clj things like yagni, kibit, yagni etc. I'm not sure how to do it in shadow-cljs:

:aliases {"eastwood"     ["with-profile" "lint" "eastwood"]
            "kibit"        ["do"
                            ["with-profile" "lint" "shell" "echo" "== Kibit =="]
                            ["with-profile" "lint" "kibit"]]
            "yagni"        ["do"
                            ["with-profile" "lint" "shell" "echo" "== Yagni =="]
                            ["with-profile" "lint" "yagni"]]
            "bikeshed"     ["do"
                            ["with-profile" "lint" "shell" "echo" "== Bikeshed =="]
                            ["with-profile" "lint" "bikeshed" "--max-line-length=140"]]
            "cljfmt-check" ["do"
                            ["with-profile" "lint" "shell" "echo" "== cljfmt check cljs =="]
                            ["with-profile" "lint" "cljfmt" "check" "src/cljs"]]
            "cljfmt-fix"   ["do"
                            ["with-profile" "lint" "shell" "echo" "== cljfmt fix cljs =="]
                            ["with-profile" "lint" "cljfmt" "fix" "src/cljs"]]
            "check-deps"   ["with-profile" "lint" "ancient" "all"]
            "lint"         ["do" ["eastwood"] ["kibit"] ["yagni"] ["bikeshed"] ["cljfmt-check"]]}

thheller10:05:16

ah ok. yeah lein plugins require lein 😉

kurt-o-sys10:05:26

(I just started using shadow-cljs, due to issues with npm, well...)

thheller10:05:20

totally fine to use lein. just curious why. lein plugins is good reason 😉

kurt-o-sys10:05:16

shadow-cljs is a breeze, btw... will present it in a workshop on http://jsconf.be

jmckitrick14:05:15

Question on the new proxy-url setting

jmckitrick14:05:49

If I’m running the cljs app on port 8020, will the proxy setting allow me to forward to a different port? I’m trying that, and it’s not working.

thheller14:05:58

the proxy setting will cause the content you proxy from to be available under 8020

thheller14:05:06

or what do you mean by cljs app?

jmckitrick14:05:29

Just the shadow server, I mean.

jmckitrick14:05:57

But that app needs an XHR call forwarded to port 9000

thheller14:05:12

:http-port 8020 :proxy-url ""

jmckitrick14:05:28

The http-port is already set to the default, I haven’t changed it.

thheller14:05:41

there is no default?

jmckitrick14:05:47

It’s set to 8020, yes, lol.

jmckitrick14:05:02

I’ll keep experimenting.

thheller14:05:13

so you do have another server running locally on port 9000 I assume?

jmckitrick14:05:32

It was http vs https

thheller14:05:16

if whatever server is running on port 9000 is capable of serving files you could just use that

thheller14:05:26

no need to use the built-in shadow-cljs server

thheller14:05:29

its just files

bhauman14:05:26

@thheller hmmm if I crib some ideas from you would you want me to mention your name and give you credit?

thheller14:05:41

@bhauman don't worry about it. I don't think there is a single new original new idea in anything I have done in shadow-cljs.

bhauman14:05:33

I thinking it would be cool to give some credit figwheel in your docs eh?

bhauman14:05:58

the absence of a mention is kind of galling

thheller14:05:13

you are absolutely right. I should definitely add a section for that.

thheller14:05:05

I have never used figwheel but definitely drew a lot of inspiration from it

bhauman14:05:35

thanks man 🙂

bhauman14:05:19

BTW i just implemented the after-load and before-load meta data hooks

bhauman14:05:32

its a pretty sweet addition

bhauman14:05:59

although I require a ^:figwheel-hooks mark on ns

bhauman14:05:33

didn't wan't to search across every var on each compile

thheller14:05:41

probably a good idea. I didn't check how long that takes after I put it in but probably should have.

javi15:05:20

I am playing with custom builds, simple, just a post build hook to copy some files as documented here https://shadow-cljs.github.io/docs/UsersGuide.html#_example.

(ns build.browser-post-process
  (:require [shadow.build :as build]
            [shadow.build.targets.browser :as browser]))

(defn core [{::build/keys [stage mode config] :as state}]
  (let [state (browser/process state)]
    (when (and (= :flush stage) (= :dev mode))
      ;; do task here
      state)))
and config :target build.browser-post-process/core in a build called b2 when running shadow-cljs watch b2 in "shadow-cljs": "^2.3.20" I get
...
...
shadow-cljs - watching build :b2
[:b2] Configuring build.
[2018-05-09 16:32:38 - WARNING] failed to handle server msg: {:type :start-autobuild}
java.lang.AssertionError: Assert failed: (build-api/build-state? %)
        at shadow.build$configure.invokeStatic(build.clj:175)
        at shadow.build$configure.invoke(build.clj:175)
...
...
am i missing something? cheers!

thheller17:05:38

@fj.abanses the build.browser-post-process/core must always return the state it receives

thheller17:05:07

you are not returning the build state properly

thheller17:05:42

you moved the state into the when

javi18:05:49

@thheller ouch!! 😞 sorry the code in the user guide has some typos and i misinterpreted it.

(ns build
  (:require [shadow.build :as build]
            [shadow.build.targets.browser :as browser]))

(defn custom [{::build/keys [stage mode config] :as state}]
  (let [state (browser/process state] 
    (when (and (= :flush stage) (= :dev mode))
      (call-rsync)
    state))
(browser/process state and also the closing paren for the (when I can fix the docs and send a pull request if it helps you.

thheller20:05:20

hmm this example is still totally incomplete

javi21:05:56

let me know if i can help testing something...

javi20:05:28

thanks. Also, in the karma settings secction

{...
 :builds {:ci-tests {:target     :karma
                     :output-to  "target/ci.js"
                     :ns-regexp  "-spec$"}
below this in the how to run snnippets the build is referenced as ci
$ shadow-cljs compile ci
$ karma start --single-run

javi20:05:14

replying to previous comment.