Fork me on GitHub
#shadow-cljs
<
2019-06-12
>
grant00:06:13

Also why I was hoping for suggestions on things to look for or places to explore. It's a react component. And if I copy the code out of node_modules and into my source (require '["/name.js" :as n :refer (Component)]) gives me the same result. Their code comes in both es and cjs versions, the cjs seems to load, but shadow throws an exception when I try to require the es version directly.

lilactown00:06:27

I would console.log the object, and see if the Component is in object

lilactown00:06:35

right now it’s hard to tell what you’re experiencing

lilactown00:06:59

you should be able to see a key :Component in the #js {…}

lilactown00:06:12

(using console.log here might be better than e.g. println)

lilactown00:06:41

you should be able to do something like: (.-Component n)

lilactown00:06:49

and see the component you’re trying to :refer to

lilactown00:06:50

if it’s just not there, I don’t know. I’d have to look at the code. there might be some other documentation they have on how to import that might be more illuminating

lilactown00:06:11

e.g. it might be in some submodule "basicchart/BasicChart" or if it’s using the ES module it might be behind a default key

grant00:06:09

Yea, I tried the console.dir and looked, the component isn't there. I tried their example code. It was JSX, so I put it through babe and added that code into my project. No dice there either.

lilactown00:06:53

how do they import it in their example code?

grant00:06:37

I wasn't sure if maybe their code didn't get along with the closure compiler, or if there was something with that exception shadow was throwing.

lilactown00:06:44

sounds like their docs are just wrong?

lilactown00:06:16

unfortunately I can’t really help you without more information

grant00:06:14

Yea, I figured it was a long shot. If it was my code I'd just share it.

grant00:06:52

The shadow exception is just Exception in thread "async-thread-macro-9" java.lang.RuntimeException: java.lang.Exception: Not supported: class clojure.lang.ExceptionInfo

grant00:06:17

And seems to complain about transit things in the stacktrace.

lilactown00:06:42

go ahead and post the whole stacktrace

lilactown00:06:58

this only shows up when compiling with this require?

grant00:06:38

Only when compiling the es version of their package code placed directly into my source path.

lilactown00:06:10

but not with the cjs version

lilactown00:06:40

i’m not sure how shadow-cljs treats JS files on the classpath tbh. I think it might do some special things for node_modules that it might not do for normal JS on the classpath

grant00:06:12

Correct, just the es, not the cjs version.

grant00:06:00

Yea, was mostly just trying to get datapoints, hoping to find a clue.

grant00:06:30

Thanks for trying to help @lilactown, I appreciate you taking the time.

thheller08:06:11

@grant do you have the full exception trace? ... 20 more seems top be cutting of the relevant parts?

thheller08:06:07

(js/console.dir x) is probably the most useful thing. I've seen JS packages that only have one default export and add properties onto that

thheller08:06:25

so if the object has a default property you might find what you are looking for there

yuhan09:06:59

I have extra-dependencies specified in a deps.edn alias that I only want pulled in for a :dev build, how can this be done?

thheller10:06:46

well you could with just clj

thheller10:06:01

clj -A:foo shadow.cljs.devtools.cli watch app

yuhan10:06:25

oh okay, would you consider a feature request for such a mapping to be specified in the shadow-cljs.edn file?

yuhan10:06:38

something like {:builds {:dev {:deps/aliases [:dev] ...} ...}}

thheller10:06:48

oh I forgot. you can also do shadow-cljs -A:foo watch app

thheller10:06:54

via the config is not an option no

thheller10:06:09

you should not have a build named :dev

thheller10:06:12

that is not how it works in shadow-cljs

yuhan10:06:23

oh.. why not? From what I understood builds can be used as a way to pull in dev dependencies and additional source paths/compiler optimizations

thheller10:06:43

no builds can not affect anything classpath related

thheller10:06:01

compiler options yes but nothing that affects dependencies or source paths

thheller10:06:58

the classpath applies to the entire started JVM

thheller10:06:13

so if you run 2 builds and both would like different dependencies that wouldn't work

thheller10:06:38

that being said you can do all of this via clj directly

yuhan10:06:45

oh right, because you can start multiple builds on a single server

yuhan10:06:56

thanks for clearing that up :)

grant12:06:51

@thheller I am trying to figure out a good way to get the full stack trace. I am seeing it on the console output of the terminal running npx shadow-cljs server. I'm triggering it by doing the (require ...) in the browser based repl that server provides.

thheller12:06:52

try with shadow-cljs browser-repl instead, the web interface might not route some output properly maybe

talgiat13:06:05

Hi, can I point to different lein configurations in different builds, for example in test build I want to include more dependancies

talgiat13:06:34

The actual problem is not being able to use test check generators when connecting to nrepl started by shadow watch test

talgiat13:06:03

getting the following error:

(gen/generate (s/gen ::open?))
Error: Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required

thheller14:06:49

did you require clojure.test.check.generators?

talgiat14:06:29

in the repl

talgiat14:06:49

so from one terminal window I ran shadow-cljs watch test

credulous14:06:00

Hi! I’m having some trouble getting my dev setup going - I’m trying to use httpkit and compojure on the server side and shadow-cljs for all the javascript. Thanks to help from @isak yesterday, I got changes to my reagent components live-reloading in the browser. However I can’t seem to get changes to the .css file to reload.

talgiat14:06:11

and from the other shadow-cljs cljs-repl test

credulous14:06:00

I do have

:devtools {:after-load alexandria.core/mount-root
                            :http-root "/"
                            }
in my shadow-cljs

thheller14:06:15

/ is definitely not correct

credulous14:06:17

I’ve played with what to put in :http-root

thheller14:06:39

it should be the path to your http root directory

credulous14:06:41

My compojure routes are serving out of /public

thheller14:06:58

you mean public in your project dir?

credulous14:06:04

Yes, sorry for being unclear

credulous14:06:38

shadow-cljs is compiling to /public/js/ in my project dir, that seems to reload well

credulous14:06:15

The css file is in /public/css/, it also loads fine from the browser.

thheller14:06:20

please be careful in your use of /

thheller14:06:25

do you actually mean /?

credulous14:06:34

I’m all ears

thheller14:06:37

your absolute file system root?

credulous14:06:47

Nope, I certainly don’t mean that

thheller14:06:05

the path are relative to your project root UNLESS you start them with /

thheller14:06:30

so it most certainly should be :watch-dir "public"

thheller14:06:44

:http-root does nothing if you don't actually use that webserver

credulous14:06:57

changed {:http-root "public"} to {:watch-dir "public"} but still no joy

credulous14:06:17

Reloads changes to the cljs files but not to the css file.

thheller14:06:59

and the css file is in public/css/foo.css with your css file included in the HTML via <link rel="stylesheet" href="/css/foo.css">?

credulous14:06:21

[email protected]: ~/dev/terrapin/alexandria $> ls public/css
total 8
drwxr-xr-x  3 rodfrey  staff    96B Jun 11 16:11 .
drwxr-xr-x  5 rodfrey  staff   160B Jun 11 16:16 ..
-rw-r--r--  1 rodfrey  staff    74B Jun 12 08:43 alexandria.min.css

credulous14:06:49

<html>
  <head>
    <script src="/js/main.js"></script>
    <script src=""></script>
    <link rel="stylesheet" type="text/css" href=""></link>
    <link rel="stylesheet" type="text/css" href="/css/alexandria.min.css"></link>
    <meta charset="utf8" />
    <title>Alexandria</title>
  </head>
  <body>
    <div id="app">Hello from Alexandria dsf</div>
    <script>alexandria.core.init()</script>
  </body>
</html>

credulous14:06:33

Here’s the actual build definition, perhaps I did something boneheaded

credulous14:06:46

{:source-paths ["src/cljs"]

  :dependencies [[bidi "2.1.6"]
                 [cider/cider-nrepl "0.22.0-beta1"]
                 [cljs-ajax "0.8.0"]
                 [com.andrewmcveigh/cljs-time "0.5.2"]
                 [kibu/pushy "0.3.8"]
                 [re-frame "0.10.6"]
                 [reagent-utils "0.3.3"]
                 [day8.re-frame/http-fx "0.1.6"]
                 [refactor-nrepl "2.4.0"]
                 [reagent "0.8.1"]]

  :builds {:alexandria {:target :browser
                 :output-dir "public/js"
                 :asset-path "/js"
                 :modules {:main {:entries [alexandria.core]}}
                 :devtools {:after-load alexandria.core/mount-root
                            :watch-dir "public"
                            }
                 }}

  :nrepl { :port 8777 }

credulous14:06:57

Restarted shadow-cljs server after changing to watch-dir and it works now

credulous14:06:04

Sorry to bother you! But thanks for the help!

credulous14:06:06

By the way, I love this system. I’ve actually been able to build up my shadow-cljs.edn and deps.edn from scratch and understand it all. I was never able to do that with lein or figwheel. Thanks for your work.

👍 8
4
✔️ 4
4
credulous14:06:26

which says more about me than it does about either lein or figwheel, but there it is.

thheller14:06:41

not really. I couldn't do that either 😛

🙂 4