@rameezkhan.sa saw your question on twitter. did you sort it out?
Nope not yet. :)
Let me get some more details...
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:
I assume by proxy you meant the :proxy
in shadow-cljs.edn for dependency resoltiuon?
{: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 [<http://timer.app|timer.app>]}}
:devtools {:http-root "public"
:http-port 3000}}
:prod {:target :browser
:output-dir "public/js"
:modules {:main {:entries [<http://timer.app|timer.app>]}}
:release {:compiler-options {:optimizations :simple}}}}}
yeah that should be :maven {:proxy ...}
Correct.
ah!
cool!
that'll then work in the other config too
nice! 🙂
Thanks for the help!
btw the :prod
build is an anti-pattern in shadow-cljs
just put the :release
bit into the :app
config
optimizations are only applied to release
builds so it does not affect the watch
or compile
builds
Ah got you! Thanks for the spot.
Learnt something new 🙂
yeah common mistake people make that have used other tools before (or read other docs) 🙂
Would you then just do shadow-cljs release app
?
yes
Cool
The proxy still doesn't seem to work globally set.
This is what I have set:
{:mvn {:proxy {:host "127.0.0.1" :port 3128}}}
file-path is: /home/rameezk/.shadow-cljs/config.edn
:maven
not :mvn
That look right?
ah cool
Apologies, that works 🙂
please give me a hint with regards to missing source maps e.g. DevTools failed to load SourceMap: Could not parse content for <http://localhost:7000/cljs-runtime/goog.events.events.js.map>: 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
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
that was it, thank you
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
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?
https://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-react-native
Thank you @thheller!
I still need a better place to configure this somehow 😛
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 <https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting>
I’m adding `{:closure-defines {"shadow.cljs.devtools.client.env.server_host" "%IP-ADDRESS%"}}` to `(shadow/watch options)` to set correct IP address
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?
Hi @trybeee, how can I get the IP address? Is it the IP of the emulator? I don't know how to get the IP
%IP-ADDRESS%
is a placeholder for your machine real ip
{:closure-defines {"shadow.cljs.devtools.client.env.server_host" "192.168.1.111"}
for instance
@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)
@jaime.sangcap 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
@trybeee 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.
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.
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 😞
@trybeee 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?
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?
Yes, client running in the emulator needs IP to connect to server which is running on your laptop
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
but if your machine has multiple IPs it sometimes picks the incorrect one. still need to tune that mechanism a little I guess.
but yes, your emulator has a different IP and connects over the "network" not localhost