Fork me on GitHub
#shadow-cljs
<
2018-02-21
>
thheller17:02:26

@denik semantic-ui-react adds 726 files to the compilation. that takes a while. shouldn't be a problem on the second compile once caching kicks in.

thheller17:02:12

you can shadow-cljs compile app --verbose to get a bit more timing related output

thheller17:02:28

-> Shadow JS converting 729 JS sources
<- Shadow JS converting 729 JS sources (3688 ms)
-> Shadow JS Cache write: 729 JS files
<- Shadow JS Cache write: 729 JS files (5814 ms)

thheller18:02:46

:verbose true in the config also works

denik18:02:49

@thheller running it with the verbose flag, cache doesn’t seem to kick in and it prints

-> Flushing 1023 sources
<- Flushing 1023 sources (108 ms)
-> Flushing unoptimized modules
<- Flushing unoptimized modules (95 ms)

denik18:02:03

btw I’m on version "2.1.10"

thheller18:02:54

ah that version doesn't have the verbose log for JS yet

thheller18:02:12

or it was names differently

thheller18:02:21

should be up top, something about convert

thheller18:02:17

the Flushing ... is just writing the final JS to disk, not the actual compilation parts

thheller18:02:43

[:browser] Build completed. (822 files, 728 compiled, 0 warnings, 18.15s)

thheller18:02:50

[:browser] Build completed. (822 files, 0 compiled, 0 warnings, 1.06s)

thheller18:02:05

without/with cache with just semantic-ui

thheller18:02:28

<- Flushing 822 sources (6966 ms)

thheller18:02:44

thats why caching is so important for these files 😛

lilactown20:02:20

so, I’m trying to use a similar workflow to the way I work in CLJ, where I send forms from my editor to the REPL, and I’m not having much success

lilactown20:02:05

even if I ns into the namespace i’m working in at the REPL, none of the vars exist unless I manually evaluate the defs at the REPL

lilactown20:02:42

evaluating forms that rely on just stuff in clojure.core works fine, though

justinlee20:02:11

@lilactown I can’t seem to get a reliable functional repl session working either, though to be fair I couldn’t get it working with the lein/ figwheel / piggieback rube goldberg contraption using the normal cljs compiler either

lilactown20:02:39

and I can refer to them by their fully qualified ns e.g. my.foo.bar/baz

lilactown20:02:18

yeah, I have a feeling this is an issue with most cljs repls - I seem to recall similar issues with figwheel. was just wondering if someone had found a way to be productive

justinlee20:02:11

oh yea that’s interesting--using a fully qualified namespace does work

justinlee20:02:39

basically i gave up and I just rely on auto-reloading code and print statements to the console

thheller20:02:23

what exactly are you doing?

lilactown20:02:16

I’m trying to try things out at the REPL as I’m developing

thheller20:02:37

be precise .. otherwise I cannot reproduce

lilactown20:02:06

I’m working on a Node.js app that serves a webpage. So e.g. I might have my-project.pages.sign-in that has some logic, makes some requests, etc.

lilactown20:02:51

I’d like to be able to evaluate forms within that namespace at the REPL. e.g. if I have (def foo "bar") inside of my-project.pages.sign-in, I’d like to evaluate foo at the REPL and see “bar” printed out

lilactown20:02:24

atm, I have to use the fully qualified namespace my-project.pages.sign-in/foo, even if I do (ns my-project.pages.sign-in) in the REPL first

thheller20:02:54

I just need what you send to the repl

lilactown20:02:55

evaluating without the fully qualified namespace results in printing “nil” unless I also evaluate the def

thheller20:02:56

(shadow.cljs.devtools.api/nrepl-select :script)
To quit, type: :cljs/quit
=> [:selected :script]
(in-ns 'demo.script)
=> demo.script
(def foo "bar")
=> #'demo.script/foo
foo
=> "bar"

thheller20:02:39

(in-ns 'cljs.user)
=> cljs.user
(ns demo.script)
=> demo.script
foo
=> "bar"

thheller20:02:34

if you ns into a namespace that is not yet loaded

thheller20:02:46

it will not load that namespace, it will just create an empty one

thheller20:02:54

you must (require 'that.ns) first to load it

lilactown20:02:56

okay, hmm… I’m having trouble reproducing it 😅

lilactown20:02:31

the only thing that’s not working once I ns into the namespace are things that are (:require)’d in the ns declaration

thheller20:02:48

are you sure that the ns is loaded?

thheller20:02:03

switching namespace you are supposed to do via in-ns not ns

thheller20:02:21

ie. if you don't have a namespace loaded and (ns that.foo) it will be empty, no defs no requires nothing

lilactown20:02:05

restarting everything to try it with in-ns

thheller20:02:14

do require first

thheller20:02:23

in-ns also only switches and does not load

thheller20:02:39

thats identical behavior to clojure though

lilactown20:02:08

I think I’m getting a bit mixed up since in my clj project it defaults to the ns my -main function is in and I often evaluate the whole file

thheller20:02:01

the CLJS workflow should pretty much work exactly like CLJ

thheller20:02:23

few subtle differences due to async stuff but for the most part it should work

lilactown20:02:40

the sign-in ns looks like:

(ns cambia.web.experience.dashboard.pages.sign-in
  (:require [cambia.web.ui.components.page-header :as page-header]
            [cambia.web.experience.dashboard.components.page-setup :as page-setup]
            [cambia.web.experience.dashboard.components.login :refer [login]]))
;; ...

(defn foobar [] "baz")

lilactown20:02:08

I expect that this is related to my newbness with clojure 😅

thheller20:02:27

page-header is an alias, you can't use that directly

thheller20:02:43

page-header/foo or whatever is in that ns

thheller20:02:37

also upgrade to fix the display-as-string-issue

thheller20:02:06

:as is only direclty usable for JS namespaces. not allowed for CLJ(S).

lilactown20:02:01

facepalmdoh! OK, thanks.

lilactown20:02:21

yeah I also realized that I’m on a really out of date shadow-cljs version, per your reply to my github issue 😛

thheller20:02:47

yeah lots of fixes since then 🙂

justinlee21:02:29

what i was trying was just trying to run a function from one of my files via proto-repl. i’ve seen video where people have (defn my-func [] ...) and then send forms that invoke it (my-func). I seem to need to run the definition manually before being able to use it. But @lilactown pointed out that it is actually loaded already but you have to use the fully qualified namespace

lilactown21:02:17

@lee.justin.m try switching to the ns that you’re trying to evaluate it in

justinlee21:02:44

it times out for me using atom + protorepl

lilactown21:02:11

(require 'my-project.core)
(in-ns 'my-project.core)
(my-func)

thheller21:02:16

I can't comment on anything proto-repl. need to know what gets sent to the repl.

justinlee21:02:43

is there a way to spy on the nrepl?

lilactown21:02:05

I’m using Emacs & CIDER. I notice that if I try and send those forms from a file to the REPL, they don’t work. but if I enter them into the REPL directly, they work

thheller21:02:05

proto-repl side I don't know. for shadow-cljs you can turn on debug logging

justinlee21:02:12

oh interesting: this is showing up in the watch terminal [2018-02-21 12:29:33 - WARNING] client sent unknown msg {:type :repl/set-ns-complete, :id 0, :ns seekeasy.util}

thheller21:02:48

that was fixed recently

justinlee21:02:29

urg. i’ve been updating shadow-cljs globally but apparently it was pegged in my package.json

justinlee21:02:13

so I think i was on an old version. confusing because I apparently imagined that i was getting bug fixes from you last week.

thheller21:02:10

yeah project version is the one that counts

justinlee21:02:38

so does the shadow-cljs binary delegate to the locally installed version?

justinlee21:02:45

ahhhh that explains it. i was testing your changes in a different test repo last week. i forgot that, which is why things seemed to go backwards

justinlee21:02:40

so things work if i manually switch namespaces using (in-ns). it would seem like protorepl should do that for me, but this does make it usable

thheller21:02:06

it might have a keybinding for that? cursive does.

justinlee21:02:55

I do a cmd-alt-b to send a form over to the repl. you’d think given that it knows what namespace i’m in when i do that, it would do a (in-ns) first

thheller21:02:43

no idea what proto-repl does. maybe there is an option for that?

justinlee22:02:03

it looks like it wraps the form in an eval and sends it in an object like this {op: "eval", code: wrappedCode, ns: ns, session: session}. I need to figure out a way to dump the actual serialized bytes being sent over the socket to tell more, but the code should be sending the namespace of the current file from which you send the form

richiardiandrea23:02:10

hello folks, is shadow-cljs using its own internal way to resolve the classpath? If so I have a feature request if possible 😄

justinlee23:02:46

it manages dependencies if that’s what you mean. what’s the request (i’m just curious)