Fork me on GitHub
#shadow-cljs
<
2019-12-30
>
pez18:12:01

I am trying to get this template project over to shadow-cljs, but am failing: https://github.com/enterlab/rente

pez18:12:14

I’m at where I get these errors in the js console:

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (style.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (main.js, line 0)
[Error] Refused to execute  as script because "X-Content-Type: nosniff" was given and its Content-Type is not a script MIME type.
[Error] ReferenceError: Can't find variable: goog
	Global Code (0.0.0.0:14)

pez18:12:04

My shadow-cljs looks like so:

{:dependencies
 [[org.clojure/core.async "0.4.490"]
  [com.stuartsierra/component "0.4.0"]
  [environ "1.1.0"]
  [ch.qos.logback/logback-classic "1.2.3"]
  [org.clojure/tools.logging "0.4.1"]

  [ring/ring-core "1.7.1"]
  [ring/ring-defaults "0.3.2"]
  [compojure "1.6.1"]
  [http-kit "2.4.0-alpha2"]

  [com.taoensso/sente "1.13.1"]
  #_[com.cognitect/transit-clj "0.8.313"]
  #_[com.cognitect/transit-cljs "0.8.256"]

  [org.clojure/tools.namespace "0.3.0-alpha4"]
  
  [reagent "0.8.1"]
  [org.webjars/bootstrap "4.2.1"]]

 :source-paths
 ["src" "dev" "resources/public"]

 :builds
 {:app {:target :browser
        :output-dir "resources/public/js"
        :asset-path "/public/js"
        :modules {:main {:entries []}}}}}

thheller20:12:11

@pez :asset-path looks incorrect. the server is likely using resources/public as a root? or probably should be?

pez20:12:21

Hmm, I have tried that, but going at it again, if I change the source-paths entry to just "resources", I get rid of the 404 errors. But now shadow-cljs shows a “Stale client” error.

thheller20:12:01

the source paths in shadow-cljs are completely irrelevant to the server part

thheller20:12:09

you are still running that through lein I presume?

pez20:12:08

Without the source path entry I git nil for any ( …) calls.

thheller20:12:22

what are you using for the server?

pez20:12:41

Trying with only shadow, so no lein involved.

thheller20:12:03

I don't get the point of that template then?

pez20:12:11

It is ring with httpkit.

thheller20:12:15

and also there is no http config in the config file you pasted

thheller20:12:31

ok so you are running the server through shadow-cljs run?

pez20:12:09

actually trying with watch.

thheller20:12:34

you lost me ... watch compiles CLJS ... it doesn't run a CLJ server

thheller20:12:53

do you use :dev-http? or a http config in :devtools?

thheller20:12:16

shadow-cljs is not made for CLJ development. you should probably be running it via lein or clj

thheller20:12:19

but I don't even understand what you are trying right now

pez20:12:34

Me neither, it seems. 😄 The server starts though… But I’ll go back to lein for that then.

thheller20:12:17

HOW are you starting it though?

thheller20:12:37

did you add something to the config that isn't in the one pasted above?

pez20:12:13

Nothing added to the shadow-cljs.edn…

thheller20:12:49

sorry then I don't know how you get a server running at :8888

thheller20:12:57

maybe something "old" leftover running?

pez20:12:51

No, that’s not it. If I quit the shadow-cljs process I have no server…

pez20:12:27

Does shadow see that there is a project.clj file there and using it somehow?

pez20:12:05

Nope. I can remove that and the server is still started…

thheller20:12:35

do you have a user.clj that starts it?

pez20:12:09

I hope not. Let me check…

pez20:12:26

Well, yes, that’s it.

thheller20:12:13

thats not starting the server on its own?

pez20:12:05

Correct, I issue (run) as part of the jack-in. This is how the template is wired. I had forgotten about that part…

pez20:12:48

I should probably go back to letting Leiningen deal with the server…

thheller20:12:11

that doesn't do anything different really ... you should maybe try to understand what is going on though 😉

thheller20:12:20

but yes .. use lein for the server

thheller20:12:25

run it separately from shadow-cljs

pez20:12:13

I expect to still have the stale client problem if I wire it up that way, but anyway.

thheller20:12:10

stale client likely means you are serving files from the wrong directory

thheller20:12:42

so sort out your paths properly. this template seems rather messy to me since I can't even figure out which paths it is serving

pez23:12:49

I got it working. Not sure what was tripping things up, but cleaning the project seemed to have to do with it, Anyway, leaving things with using only shadow-cljs in dev, for now. I’m not doing anything fancy enough to need Leiningen, yet.