Fork me on GitHub
#shadow-cljs
<
2018-12-27
>
this.rob09:12:19

@thheller thanks. Have set that flag, and also :autoload and :ignore-warnings to true: https://github.com/thisdotrob/shadow-cljs-node-hot-code-reload

this.rob09:12:47

but it still isn't running the hooks :white_frowning_face:

thheller09:12:43

@rs works for me?

thheller09:12:59

__filenamex /mnt/c/Users/thheller/code/shadow-cljs/tmp/shadow-cljs-node-hot-code-reload/out/demo-script/script.js
starting server
http server running
stop called
stop completed undefined
__filenamex2 /mnt/c/Users/thheller/code/shadow-cljs/tmp/shadow-cljs-node-hot-code-reload/out/demo-script/script.js
start called
starting server
http server running

this.rob09:12:16

My bad, didn't realise you still had to run the script separately with node!

this.rob09:12:34

I was trying to replicate my other shadow-cljs project's setup which starts serving up a re-frame app straight automatically after compiling, but for node-script. More investigation needed simple_smile

thheller09:12:27

well if its re-frame you probably open it in a browser?

thheller09:12:37

node script you need to run manually yes

this.rob09:12:23

Yep open it in a browser, but I have :http-root and :http-port so it is being served up automatically after compiling

this.rob09:12:43

was hoping to have a similar setup for my node server, with it starting automatically

this.rob09:12:09

perhaps this is beyond the scope of shadow-cljs' responsibilities though

thheller09:12:58

@rs nothing starts automatically with a browser app. you need to open it otherwise nothing else happens. the http server literally just serves files nothing else.

thheller09:12:22

node server starting is out of scope yes since you may need stdin or just want a CLI script to exit

thheller09:12:38

you can always use shadow-cljs node-repl and do things manually but it won't execute hooks

orestis10:12:29

@thheller I’m trying to get started with a local fork of shadow — are there any more instructions than CONTRIBUTING.md ?

thheller10:12:11

@orestis depends on what you want to do?

thheller10:12:53

don't need a local fork for that

orestis10:12:30

I want to tweak the way that shadow injects the hud.

orestis10:12:00

Oh, that’s neat.

thheller10:12:11

that should override whatever shadow-cljs ships

thheller10:12:11

I can probably fix this if you provide a full stacktrace

thheller10:12:32

no idea how to get it in ie11 but I'm pretty sure there is a way to get it

orestis10:12:41

Unfortunately IE11 on a VM isn’t exactly user friendly in that regard 🙂

orestis10:12:45

But let me see.

thheller10:12:10

yeah ie11 has horrible dev tools but I think the console still shows a trace

orestis10:12:59

shadow.dom.append.cljs$core$IFn$_invoke$arity$2 [Line: 867, Col: 1], shadow.dom.js
shadow.cljs.devtools.client.hud.dom_insert.cljs$core$IFn$_invoke$arity$2 [Line: 360, Col: 1], shadow.cljs.devtools.client.hud.js
shadow.cljs.devtools.client.hud.dom_insert.cljs$core$IFn$_invoke$arity$1 [Line: 342, Col: 1], shadow.cljs.devtools.client.hud.js
shadow$cljs$devtools$client$hud$connection_error [Line: 770, Col: 1], shadow.cljs.devtools.client.hud.js
Anonymous function [Line: 1038, Col: 1], shadow.cljs.devtools.client.browser.js

orestis10:12:27

This is what I see in the “call stack” — unfortunately not source-mapped.

thheller10:12:11

so it fails to connect to the shadow-cljs server I guess

thheller10:12:28

connection-error is trying to display a warning and that fails

orestis10:12:45

I don’t think that’s it — my hunch is that body is not available yet when I load my code.

thheller10:12:05

shadow$cljs$devtools$client$hud$connection_error is pretty clear in what it does 😉

orestis10:12:21

Ah, cool — yes, it wouldn’t be able to do the connection because it’s running in a VM.

orestis10:12:32

But still the hud is the one breaking, right?

thheller11:12:50

you could run shadow-cljs compile your-build

thheller11:12:02

that won't load the hud and stuff, so it can't error out on startup

thheller11:12:39

or you can set :devtools {:devtools-url ""}

thheller11:12:50

if the VM can connect to that server

orestis11:12:20

I might need to proxy that shadow websocket anyway, because then things like browserstack can never work. I want to get my designers a way to see their changes live on many different browsers.

thheller11:12:43

ok then you need to figure out why the websocket fails connecting

orestis11:12:57

Still though, I think the fact that hud/dom-insert is using js/document.body is a little smelly 🙂 I’ll see if I can tweak that to make sure the error reporting works.

thheller11:12:58

its bad that it fails to show that error but thats not causing the error

thheller11:12:24

it can't show the error if there is no document.body 😉

orestis11:12:04

Yes, of course — this is caused because I load my CLJS in head (long story, unavoidable unfortunately). Many things break 🙂

orestis11:12:39

It’s funny how most of us now assume that JS is going to be loaded at the end of the body element.

thheller11:12:35

head is not the issue here

thheller11:12:10

all of this happens async. I don't know why IE11 even attempts to connect while body is not present

thheller11:12:18

its supposed to finish loading first

orestis11:12:05

I’m trying to override hud.cljs. I’ve placed it right in my source path, path is <source-path>/shadow/cljs/devtools/client/hud.cljs but my changes don’t seem to have any effect. Am I doing something wrong?

thheller11:12:32

probably need to restart the server process if that is still running (ie. watch)

orestis11:12:26

So the moment this the websocket error happens, the hud tries to show the connection error and then blows up.

orestis11:12:01

What would be the downside of replacing the setTimeout to a DOMContentLoaded event?

thheller11:12:38

did ie11 have domcontentloaded? can't remember

thheller11:12:50

but yeah that would be fine by me

orestis11:12:46

Ok, replacing files works, I’ll have a look about replacing that and report back.

orestis11:12:04

Perhaps there’s a Google Closure way to do this safely.

orestis11:12:53

Is there a minimum browser version for shadow?

thheller11:12:29

dunno. not sure I want to support ancient browsers. I hate ie11 enough for work I don't really want to deal with it elsewhere 😉

orestis11:12:57

DOMContentLoaded goes back to IE9.

thheller11:12:19

ok definitely not interested in supprting ie8 😉

orestis11:12:42

What about sth like: (if js/document.body (current-behaviour) (try-later))

orestis11:12:05

this would be replacing the existing (js/setTimeout (ws-connect))

orestis11:12:27

Still though, seems off to delay connecting the websocket until the document is ready.

thheller11:12:47

no it should always be async

thheller11:12:53

so other load events can fire first

orestis11:12:11

OK, I’ve got this working — on to the next hurdle: getting a relative :devtools-url to work. It seems the code in env/ws-url expects a full url because it tries to replace http with ws.

orestis11:12:53

I’d like to have my devtools-url be /shadow-cljs-server so that it goes to whatever the serving address is…

thheller12:12:20

it defaults to using the url you load the page from

thheller12:12:28

since that is usually what you want

thheller12:12:48

it must be a full url since its needed for ws and xhr requests

orestis12:12:43

Ah, what about if I want to keep the host the same but use another port?

thheller12:12:12

that is the default?

orestis12:12:17

whoops, sorry, reuse the same port and host. So my webserver is responsible to proxy the traffic.

orestis12:12:30

Just to clarify: I’m loading my page from . I want to instruct shadow to connect to . But I’m also loading my page from , so I want then the connection to be

orestis12:12:18

I’ll make a PR for all this, BTW.

orestis12:12:52

Hm, replacing env.cljs doesn’t seem to take any effect. I wonder if all the google-closure defines at the top have anything to do with it.

orestis12:12:35

I need to break for lunch but I’ll be back 🙂

thheller12:12:24

need to restart the watch/server to replace the file I guess

orestis12:12:56

Yeah, I did that for the other cases but env.cljs is stubborn…

orestis13:12:44

What a wild goose chase. Turns out the default behaviour of shadow is just right — it’s trying to connect to “whatever-host-you-have:9630” which should just work for all my use cases. But, IE11 inside that VM complains with: SCRIPT12008: WebSocket Error: Incorrect HTTP response. Status Code: 200, OK

thheller13:12:39

it shouldn't answer with that though? should get an upgrade response? is a proxy or something active?

orestis14:12:53

This is definitely IE11 specific. Chrome inside that VM is working correctly with the default shadow settings.

orestis14:12:13

I suspect something about security things but I’m not quite sure how to troubleshoot this.

orestis14:12:02

To clarify: shadow’s default that connects to ... works just fine when using chrome inside a VM and safari outside the VM, where original-host is different. It’s only IE11 that complains with that cryptic error.

thheller14:12:11

no idea what it might do differntly

orestis14:12:40

I give up. IE11 on windows 10 manages to connect succesfully. Funnily enough, there, reloading only works with dev tools open. Otherwise I get a shadow hud saying: [reload failed] invalid calling object

orestis14:12:01

If I open the dev tools, then reload works as expected.

orestis14:12:33

I’ll update my issue with all this info, and a PR for the websocket connection on document load.

orestis14:12:52

Thanks for the guidance!

thheller14:12:54

@orestis I had one of those issues with IE before. forgot the details though. something to do with standards/quirks mode

orestis14:12:57

Highly probable.

orestis14:12:42

All I want is my designers to be able to quickly preview CSS/markup changes on both IE11 and modern browsers. Having the devtools open is not a deal breaker for this, so I’ll stop exploring for now.

orestis14:12:14

I’ve opened a PR for this. Thanks for all the help and for shadow itself 🙂

orestis16:12:25

I wonder, is that barrage of document.writes something that shadow-cljs controls? Or does it come from some lower level?

orestis16:12:00

I mean, the loading of the various clans-runtime stuff when in development mode.

orestis16:12:56

It makes working with browserstack (where the VM running the browser is far away) a tad painful.

thheller17:12:13

@orestis you can set :devtools {:loader-mode :eval}. should make things faster.

orestis17:12:11

Have you considered having a patreon page or re-applying for Clojurists together? Your work is hugely important :)

☝️ 17
thheller17:12:37

I have and I will. Just didn't have time this cycle

👍 9
lambdalove 21