shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
fabrao 2020-11-04T00:22:36.268600Z

Hello all, I´m sorry about my dumb question, but is there any way to see the source of clojurescript in browser source?

Elso 2020-11-04T08:57:08.270300Z

https://github.com/binaryage/dirac

fabrao 2020-11-04T00:22:59.268900Z

using shadow-cljs?

fabrao 2020-11-04T02:09:10.269500Z

or how to use shadow-cljs with external http server?

Elso 2020-11-04T09:00:54.270800Z

I don't really understand the question. You want an arbitrary server to serve the JS that is compiled by shadow? It should be enough to include the JS in some page then and serve that while running the shadow watch-job. That is not different than using shadow with a Ring webserver and I guess you'll find some tutorials on how to set that combination up.

fabrao 2020-11-04T09:33:24.272800Z

Hello, I thougth that would be a problem with showing .cljs source in browser

fabrao 2020-11-04T09:33:59.273Z

I´ve read that .cljs source in browser is a shadow-cljs limitation

Elso 2020-11-04T16:24:27.296Z

Eh yeah I think my answer was actually nonsense too - https://stackoverflow.com/questions/60543802/get-sourcemapped-source-place-in-browser

Elso 2020-11-04T08:57:34.270600Z

2020-11-04 09:21:57,377 [XNIO-1 I/O-1] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1 How do I turn this off on the shadow-cljs server log? my SLF4J config has an entry <logger name="org.xnio.nio" level="warn" /> but it doesn't seem like shadow reads that.

thheller 2020-11-04T09:28:22.271900Z

@d.eltzner012 the logger org.xnio.nio doesn't affect io.undertow so you need to add that too. its your logging setup so you need to configure it.

thheller 2020-11-04T09:30:09.272700Z

@fabrao I do not understand the questions. you can use any webserver you want. just serve the generated .js files like any other static file.

fabrao 2020-11-04T10:03:31.274100Z

@thheller Sorry, I thougth that custom server would be a problem about not showing `.cljs` source in browser. Now I know that is a shadow-cljs limitation

thheller 2020-11-04T10:04:05.274500Z

I do not know what you mean by "showing .cljs source in browser"

fabrao 2020-11-04T10:05:19.275400Z

source map, that you can see the clojurescript source in browser

thheller 2020-11-04T10:05:32.275600Z

that works completely fine with shadow-cljs

fabrao 2020-11-04T10:05:54.276100Z

:thinking_face:

thheller 2020-11-04T10:05:59.276300Z

the only thing you have to watch out for is setting the correct :asset-path in your build config

fabrao 2020-11-04T10:06:31.276700Z

:output-dir "resources/public/js"
                :asset-path "/js"

thheller 2020-11-04T10:06:52.277100Z

assuming you load your JS via <script src="/js/main.js"> that is correct yes

fabrao 2020-11-04T10:07:46.277400Z

yes <script src="/js/main.js" type="text/javascript"></script>

thheller 2020-11-04T10:08:08.277700Z

ok looks fine

thheller 2020-11-04T10:08:59.278700Z

do you get warnings/errors when loading the page about missing source maps? otherwise it should just work (assuming you are talking about watch or compile builds)

thheller 2020-11-04T10:09:06.279100Z

release does not have source maps enabled by default

fabrao 2020-11-04T10:09:12.279300Z

thheller/shadow-cljs {:mvn/version "2.11.2"}

thheller 2020-11-04T10:09:59.280200Z

source maps have worked forever so shadow-cljs version doesn't matter much. this is fine.

fabrao 2020-11-04T10:10:05.280500Z

is there any pre-version for this/

fabrao 2020-11-04T10:10:05.280600Z

?

thheller 2020-11-04T10:10:31.281100Z

would help if you described what you expect to work and doesn't work as expected

fabrao 2020-11-04T10:11:08.282Z

if I got any error, it shows up into .cljs not in .js

thheller 2020-11-04T10:11:34.282600Z

assuming that error actually occured in CLJS that should work fine

fabrao 2020-11-04T10:11:35.282700Z

it only show by .js

fabrao 2020-11-04T10:12:14.283800Z

If I go to sources from browser, do I have to see the .cljs over there?

thheller 2020-11-04T10:12:15.283900Z

but you said something about external webserver? did you make sure that server does serve source maps correctly?

thheller 2020-11-04T10:12:31.284100Z

yes CLJS sources should be listed

thheller 2020-11-04T10:13:05.284900Z

/js/cljs-runtime/cljs/core.cljs for example

fabrao 2020-11-04T10:13:19.285300Z

it´s pedestal from lacinia graphql, and I included the part about serving other stuffs

thheller 2020-11-04T10:13:46.285600Z

well just open the webpage in chrome or whatever with the devtools open

thheller 2020-11-04T10:13:53.286Z

it should complain if it fails to load source maps

fabrao 2020-11-04T10:14:24.286400Z

thheller 2020-11-04T10:14:38.287Z

you can also just try loading <http://localhost:8080/js/cljs-runtime/cljs.core.js.map> (or whatever port you are on) to see if its served correctly

thheller 2020-11-04T10:14:56.287300Z

yeah looks like source maps are missing

fabrao 2020-11-04T10:15:56.287900Z

yes, in that url took a map to download

thheller 2020-11-04T10:16:35.288500Z

it should be served with application/json mime type

thheller 2020-11-04T10:16:52.288800Z

maybe you need to configure that in your webserver

fabrao 2020-11-04T10:17:54.289500Z

I tried with other samples, and it happens the same problem

thheller 2020-11-04T10:18:05.289800Z

but the browser should be giving you a warning about this too

fabrao 2020-11-04T10:19:43.289900Z

fabrao 2020-11-04T10:21:14.290800Z

I tried in Edge and it works :thinking_face::thinking_face:

fabrao 2020-11-04T10:21:38.291100Z

thheller 2020-11-04T10:21:47.291600Z

yeah no clue. looks fine.

fabrao 2020-11-04T10:21:59.291900Z

in Chrome it´s not working

fabrao 2020-11-04T10:22:07.292200Z

WTF?

fabrao 2020-11-04T10:22:33.293100Z

lol, I got 2 days trying to figure it out

thheller 2020-11-04T10:22:46.293400Z

maybe you have a bad service worker running or so? some bad cache?

thheller 2020-11-04T10:22:55.293700Z

or maybe some browser extension messing with things?

fabrao 2020-11-04T10:23:23.294200Z

I can bet it would be McAfee AV

fabrao 2020-11-04T10:24:43.294500Z

man, that´s insane

fabrao 2020-11-04T10:26:58.295200Z

Firefox is ok too, the only problem is that with McAfee WebAdvisor

thheller 2020-11-04T10:44:52.295400Z

no clue. never used that.

fabrao 2020-11-04T10:51:23.295900Z

thank you for your time !!!

Elso 2020-11-04T16:37:20.296800Z

woops sorry, I'm blind. actually was not "my logging setup" in that someone else set it up and I didn't find the time to deal with it yet. sorry to bother with that

Rico Meinl 2020-11-04T18:07:39.298600Z

Is there any way to disable the hot reloading for target :chrome-extension? I tried :devtools {:autoload false} and it didnt work

thheller 2020-11-04T19:34:39.298900Z

might be a bug if that doesn't disable it. why do you want to disable it?

Rico Meinl 2020-11-05T09:47:36.321300Z

Thanks a million. Seems to work now

Rico Meinl 2020-11-04T19:40:26.301300Z

Cause it messes up the reloading of my chrome extension. If I use compile after every code change it works, but the watch inserts multiple instances of the content script

Rico Meinl 2020-11-04T19:40:52.302Z

Could you make it a variable?

thheller 2020-11-04T19:45:06.302200Z

sure

thheller 2020-11-04T19:46:13.302400Z

why does it insert multiple instances? its your code doing that no?

Rico Meinl 2020-11-04T19:48:06.304300Z

Yeah it is. I'm trying to set it up in a way that I don't have to reload the web page for every code change. If it works with the auto load to false I'm happy to share the setup. It would make the chrome extension development 10x faster

thheller 2020-11-04T19:50:01.304500Z

should be fixed in 2.11.7