Fork me on GitHub
#shadow-cljs
<
2021-02-02
>
thheller09:02:45

@rameezkhan.sa saw your question on twitter. did you sort it out?

Rameez09:02:22

Nope not yet. :)

Rameez09:02:32

Let me get some more details...

Rameez09:02:43

I'm behind a corporate HTTP proxy currently, if I specify proxy details as follows in my projects local shadow-cljs.edn it works fine:

thheller09:02:46

I assume by proxy you meant the :proxy in shadow-cljs.edn for dependency resoltiuon?

Rameez09:02:55

{:source-paths
 ["src"]

 :proxy {:host "127.0.0.1" :port 3128}
 :nrepl {:port 9000}

 :dependencies
 [[cider/cider-nrepl "0.25.8"]
  [reagent "1.0.0"]
  [re-frame "1.1.2"]]

 :builds {:app {:target     :browser
                :output-dir "public/js"
                :modules    {:main {:entries []}}
                :devtools   {:http-root "public"
                             :http-port 3000}}

          :prod {:target     :browser
                 :output-dir "public/js"
                 :modules    {:main {:entries []}}
                 :release    {:compiler-options {:optimizations :simple}}}}}

thheller09:02:07

yeah that should be :maven {:proxy ...}

thheller09:02:19

that'll then work in the other config too

Rameez09:02:26

nice! šŸ™‚

Rameez09:02:30

Thanks for the help!

thheller09:02:56

btw the :prod build is an anti-pattern in shadow-cljs

thheller09:02:10

just put the :release bit into the :app config

thheller09:02:53

optimizations are only applied to release builds so it does not affect the watch or compile builds

Rameez09:02:05

Ah got you! Thanks for the spot.

Rameez09:02:19

Learnt something new šŸ™‚

thheller09:02:31

yeah common mistake people make that have used other tools before (or read other docs) šŸ™‚

šŸ‘ 3
Rameez09:02:31

Would you then just do shadow-cljs release app ?

Rameez09:02:13

The proxy still doesn't seem to work globally set.

Rameez09:02:18

This is what I have set:

Rameez09:02:30

{:mvn {:proxy {:host "127.0.0.1" :port 3128}}}

Rameez09:02:52

file-path is: /home/rameezk/.shadow-cljs/config.edn

thheller09:02:55

:maven not :mvn

Rameez09:02:57

That look right?

Rameez09:02:29

Apologies, that works šŸ™‚

šŸ‘ 3
Aron16:02:22

please give me a hint with regards to missing source maps e.g. DevTools failed to load SourceMap: Could not parse content for : Unexpected token < in JSON at position 0 the < part is because the static server returns the index.html, but the file is missing too. I am not even sure if the file should or shouldn't exist and I don't need the source maps right now at all, but I suspect I am doing something wrong again and that's why I have these warnings

thheller16:02:19

my guess is you have :asset-path "/" but the files aren't actually located there. it should match the path you use to serve the JS. so maybe /js or so

Aron16:02:46

that was it, thank you

Aron16:02:34

funny thing is, i did check the files by name before and i saw some source map files, but not exactly the one i was checking and i concluded it must be something else, not just a path issue

hadils16:02:49

Hi. I am having problems with hot reload. I ran shadow-cljs watch app --verbose and found that it was using a different IP address than expo. How can I get them to be the same?

thheller17:02:23

I still need a better place to configure this somehow šŸ˜›

jaime23:02:08

Hi, I'm trying to run cljs-test in repl in my react-native project. But I'm getting this error when the app loads in the emulator EDIT: error has changed

[Wed Feb 03 2021 03:48:56.126]  WARN     The shadow-cljs Websocket was disconnected.
[Wed Feb 03 2021 03:48:56.127]  ERROR    shadow-cljs - remote-error {"isTrusted": false, "message": "failed to connect to /10.212.134.22 (port 9630) from /10.0.2.16 (port 36722) after 10000ms"}
Now when I send forms to repl, I got this error
No available JS runtime.
See 

dima13:02:42

Iā€™m addingĀ `{:closure-defines {"shadow.cljs.devtools.client.env.server_host" "%IP-ADDRESS%"}}`Ā toĀ `(shadow/watch options)`Ā to set correct IP address

thheller15:02:22

what the heck does this do? is this some kind of trick I don't know about? what is %IP-ADDRESS%? or do you just set the actual IP there?

jaime20:02:32

Hi @U051091NM, how can I get the IP address? Is it the IP of the emulator? I don't know how to get the IP

dima09:02:31

%IP-ADDRESS% is a placeholder for your machine real ip

dima09:02:06

{:closure-defines {"shadow.cljs.devtools.client.env.server_host" "192.168.1.111"} for instance

dima09:02:43

@thheller server_host is used here https://github.com/thheller/shadow-cljs/blob/3e559b8f9ea80cc1ad1c51772fe4aa8c099a1159/src/main/shadow/cljs/devtools/client/env.cljs#L84 if not set, it uses ā€œlocalhostā€ which doesnā€™t work in iOS simulator (it needs ip address to connect)

dima09:02:16

@UNL0HK5ME It needs to be IP address of your host machine (where shadow-cljs is running), on mac you can get it with ipconfig getifaddr en0 where en0 is your network interface

thheller09:02:45

@U051091NM well for react-native there is :local-ip "1.2.3.4" in your build config or via config merge. going through closure-defines is kinda backwards. just thought there was some magic %IP-ADDRESS% placeholder or something that metro will replace but I guess not.

dima11:02:33

Thanks @thheller Nice to know there is local-ip option. At the time i was adding hack with server-port override, it wasnā€™t there i think.

thheller11:02:28

that has always been there, just not documented. I don't do react-native myself so the entire section of the code and docs is lacking a lot of clarity šŸ˜ž

jaime16:02:41

@U051091NM thanks! I will try that one. The whole time I'm thinking shadow and emulator are running in localhost. I want to dig more into the architecture, do you have recommended resources that I can read?

jaime17:02:48

Thanks! it works now by specifying the LAN IP. If I understand correctly now, my laptop running the shadow-cljs and emulator will be two device connected to the LAN. When shadow-cljs runs in localhost, the websocket client running in the emulator tries to connect to localhost which is then the emulator not my laptop? Where the solution to put the specific IP will make the websocket client point to my laptop LAN IP which is where the websocket server is running right?

dima17:02:38

Yes, client running in the emulator needs IP to connect to server which is running on your laptop

thheller17:02:50

technically it doesn't use localhost by default for react-native. it uses the IP it gets from your system. specifically this part of the code

thheller17:02:28

but if your machine has multiple IPs it sometimes picks the incorrect one. still need to tune that mechanism a little I guess.

thheller17:02:00

but yes, your emulator has a different IP and connects over the "network" not localhost

jaime18:02:46

Thanks @thheller @U051091NM for these pointers. I learned something new again