Fork me on GitHub
#shadow-cljs
<
2018-09-17
>
Hukka12:09:04

Hm. I'm pretty sure my cljs repl seemed to work fine, but now it doesn't have any readline support. That is, can't use previous commands or edit the current line without deleting it

Hukka12:09:31

Using watch and then cljs-repl app

Hukka12:09:05

Seems like it's trying to start a new nrepl server, failing due to port being bound, and then launching it in different port

thheller12:09:11

is that a question?

thheller12:09:39

cljs-repl never had any readline support natively?

Hukka12:09:22

I guess I remember wrong... Guess it was from the piggieback days

Hukka12:09:38

Who's this jiyinyiyong? I noticed just now that there's been a bunch of new releases by him, but no commits

thheller12:09:35

its @jiyinyiyong. he volunteered doing the release stuff on github. he also created http://shadow-cljs.org.

Hukka12:09:28

So, what's the recommended way to get a fully featured cljs repl with shadow? Go via clj repl and (shadow/repl :app)?

thheller12:09:29

there is no readline support there either. the recommended way is to hook up your editor properly.

thheller12:09:36

or use rlwrap

thheller12:09:46

or wait till have I the REPL hooked up to the UI (which I'm currently working on)

Hukka12:09:31

I'll use lein repl :connect for now

Hukka12:09:18

Hmh, that doesn't work that well 😕. The first time I connect with browser, things are ok. The second time I can't require anything successfully. The require passes, but using the namespace always just complains about ReferenceError

thheller12:09:55

gonna need more info. full errors help a lot.

Hukka12:09:35

The disconnect/connect is when I refresh the page in the browser

thheller12:09:21

yeah. think about it. the code is loaded by the browser

thheller12:09:31

if you reload the browser all state it had previously loaded is gone

thheller12:09:06

this is kind of a problem with the REPL since the server part still thinks that the namespace is loaded

thheller12:09:31

this is true for all CLJS repls though

thheller12:09:15

gets even more fun if you connect with 2 different browsers at different times

thheller12:09:42

I can probably fix the require to trigger the include again though

Hukka12:09:23

Ah, so the require checks some "cache" or something and does a null op?

thheller12:09:12

not some cache. it only checks the analyzer state and compiles it if necessary. it is not in this case so it does nothing

thheller12:09:44

but it should probably still tell the runtime to load the ns

Hukka12:09:33

Is there an explicit command for loading the namespace?

thheller12:09:36

thinking about it ... yeah this is definitely a bug

thheller12:09:54

the watch worker shouldn't make any assumptions about which namespaces the client has loaded

thheller12:09:01

I'll fix that

claudiu13:09:07

Hi, Silly question but can't seem to get it right. I am running some clojurescript code on nodejs and I get goog.net.xmlhttp.js:175 return new XMLHttpRequest(); ReferenceError: XMLHttpRequest is not defined. Any idea how I can set something like global.XMLHttpRequest = require('node-http-xhr'); ?

thheller13:09:51

best way probably is to create a helper namespace

thheller13:09:47

(ns my.xhr-shim (:require ["node-http-xhr" :as xhr])) (set! js/global.XMLHttpRequest xhr) and include that in your :main namespace

thheller13:09:18

probably as the very first require to ensure its loaded before the others

claudiu13:09:17

awesome 🙂 thank you 🙂

thheller13:09:08

@tomi.hukkalainen_slac the issue is will be fixed in the next release. the require will then do what you'd expect.

thheller13:09:18

will release probably later today