Fork me on GitHub
#shadow-cljs
<
2018-05-22
>
thheller07:05:37

@wilkerlucio typically I'd say this is due to the charset of the page. <meta charset="UTF-8"> typically fixes it for the browser. not sure about chrome extension though.

thheller09:05:06

@wilkerlucio there seems to a be a long history related to this. in short CLJS will emit console.log("\u25B6\u2764\u25C0"); which works fine without setting a charset. Closure will optimize and turn that into console.log("▶❤◀"); however which then fails to load properly without a specified charset. see https://dev.clojure.org/jira/browse/CLJS-1547?focusedCommentId=42617

thheller09:05:02

apparently the default charset is the problem here. if you set :compiler-options {:closure-output-charset "US-ASCII"} it will keep the same escaped sequence that CLJS emits and the problem goes away

thheller09:05:32

wonder if you can set the default charset for chrome, seems weird that it doesn't load UTF-8 properly by default

thheller10:05:44

oh right. chrome does the right thing for the extension. the browser seems to require a charset though

mhuebert17:05:54

hmm. i’m playing around with a bootstrapped build, wondering about how one might get a watch build to send updates to the browser. Seems a two-part problem; first, figuring out how to get (require 'the-ns :reload) to work (currently I have to dissoc a namespace from :cljs.analyzer/namespaces before it will do anything), maybe modifying shadow.cljs.bootstrap.browser/load-namespaces to accept a :reload parameter, and second - any idea how a client could be notified when namespaces in a bootstrapped build are modified? i would guess one just wants a callback to be fired, maybe w/ a list of changed namespaces, as there is no way for shadow to know anything about what’s going on with compiler states in the browser

wilkerlucio17:05:28

@thheller thanks! I'll try that out

thheller17:05:53

@mhuebert you are talking about the bootstrap support build notifying the host build correct?

thheller17:05:08

not sure how to do that given the complexity of self-host itself

thheller17:05:33

sending a websocket message to the host build is easy enough

thheller17:05:01

but getting it to the right place might be tough

mhuebert17:05:14

I would think the host build would need to do the work of putting it in the right place

thheller17:05:44

yeah but currently there is no way for you to "hook" into anything the devtools client is doing

thheller17:05:04

its complex enough as it is so I don't want to introduce another layer that might cause problems

thheller17:05:50

how does the self-host part deal with :reload?

thheller17:05:21

it should be able to just load other content right?

mhuebert17:05:33

yes. the only nit there is the first problem i mentioned above - i am not sure exactly where to fix it - that i have to dissoc the ns from the compiler-state before load-namespaces will reload it

mhuebert17:05:20

but when i do that, it all works

mhuebert17:05:29

the only thing i am missing is some way of knowing that a ns has changed

thheller17:05:40

it would probably be best if you implemented your own shadow.cljs.bootstrap.browser. I implemented that as a proof of concept but what you are asking goes way beyond what I planned for it

mhuebert17:05:44

I don’t think that part will be so hard on my side.

mhuebert17:05:56

i am already running the watch build from a script via clj-run, maybe there is a way i can make a little hack to listen in for when shadow has recompiled things in my bootstrap build?

mhuebert17:05:06

gotta get dinner, bbl

thheller17:05:03

I do have plans for a generic API endpoint I want to build the UI on-top of. this would expose such data but thats pretty much in planning stages

thheller17:05:35

did a few tests for graph queries using pathom but thats about it

thheller17:05:59

since you'd probably need a websocket for subscription-ish things that is even further from existing

thheller17:05:40

I guess you could build you own http server that you then connect a websocket to and notify whenever a compile finishes

grav20:05:02

$ shadow-cljs compile em-admin
shadow-cljs - config: /Users/grav/repo/eddie-michel/em-poc/shadow-cljs.edn  cli version: 2.3.23  node: v8.6.0
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm compile em-admin
Exception in thread "main" java.lang.RuntimeException: No such var: module-graph/validate-inputs, compiling:(shadow/build/cljs_closure.clj:931:3)
	at clojure.lang.Compiler.analyze(Compiler.java:6792)
What to do?

grav20:05:42

I’m using :lein true in my shadow-cljs.edn, and I’ve added [thheller/shadow-cljs "2.3.23"] to the deps in my project.clj

grav20:05:13

ah, needed to upgrade clojurescript dep to newest 1.10.238.

grav21:05:39

Hmm … cannot seem to get namespaces with dash (`-`) to work. For instance, a namespace, my-package.namespace I would assume maps to my_package.namespace, but that ends up being undefined. Works if I remove the dash from the namespace and use e.g. mypackage.namespace

mhuebert22:05:46

@thheller so to know what to send the client, I could do something like this -

(def proc (watch))

 (def output-chan
   (let [c (chan)]
     (tap (:output-mult proc) c)
     c))

 (defn bootstrap-compiled-sources [{:keys [type build-config info]}]
   (when (and (= :build-complete type)
              (= :bootstrap (:target build-config)))
     (:compiled info)))

 (def bootstrap-loop
   (go-loop []
     (let [evt (<! output-chan)]
       (some-> (bootstrap-compiled-sources evt)
               (println))
       (recur))))