shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
fsd 2021-04-26T15:10:42.482400Z

Hello There, I have a quick question, I am new in clojure How do I use png file in cljs? I have a shadow cljs application for example "./icons/marker.png I’ve tried using this but it’s not loading

thheller 2021-04-26T15:13:25.483700Z

how are you embedding it? this is not a CLJS question really, more HTML specific. if you use ./ in the path it'll be relative to the page you are on. you need to make sure the path is correct.

Azzurite 2021-04-26T15:14:49.483800Z

This has nothing to do with shadow-cljs, try #beginners or #clojurescript But generally, you need to start a webserver and serve that file on the webserver you started shadow-cljs has https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http, but you don't want to use that for your final app...

sova-soars-the-sora 2021-04-26T18:18:58.484600Z

Hi, how can I name the file something other than main.js?

Aron 2021-04-26T18:19:25.484900Z

this caught me too, the key in the map decides

sova-soars-the-sora 2021-04-26T18:20:47.485100Z

Aha

sova-soars-the-sora 2021-04-26T18:21:01.485300Z

thank you @ashnur

2021-04-26T20:31:44.486500Z

Hi there. Is it possible to invalidate the node_modules cache without restarting npx shadow-cljs watch app ? Any option?

thheller 2021-04-26T20:32:46.486800Z

invalidate why? I mean what do you expect that to achieve?

2021-04-26T20:35:10.488500Z

I put some console.log on npm package for debugging.

thheller 2021-04-26T20:35:40.489400Z

you can touch node_modules/that-package/package.json to trigger a recompile

👍 1
2021-04-26T20:36:13.489900Z

I don't have any output, so I supposed that's because Shadow cache.

2021-04-26T20:36:23.490200Z

Oh perfect, thx!

thheller 2021-04-26T20:37:04.490900Z

yeah I removed individual file watching for node_modules files because some projects used like 5000 files from there and that was causing some performance issues

thheller 2021-04-26T20:37:20.491300Z

but it still watches package.json files in cause you npm install stuff or so

thheller 2021-04-26T20:37:37.491600Z

touching the package.json will invalidate the entire package

2021-04-26T20:40:09.492300Z

Yeah I understand, very good reason performance wise. Thanks Thomas.

pez 2021-04-26T20:46:21.493300Z

Is there a reason I should defonce my app-db in a re-frame project from a hot-reload perspective?

thheller 2021-04-26T20:49:26.493800Z

yes, without it the hot-reload will just replace it with a new atom when you modify the file

thheller 2021-04-26T20:50:05.494300Z

defonce is needed if you want to keep your state

pez 2021-04-26T20:51:44.495600Z

The state seems to be kept in the re-frame.db/app-db ratom. I notice no difference when I use def on my app-db. hot reload seems to work the same.

thheller 2021-04-26T20:52:19.496100Z

then I don't understand your question. when using re-frame you don't have your own app-db?

pez 2021-04-26T20:57:10.000200Z

I am asking because I am going to present ClojureScript app development on a meetup Wednesday. And I had sort of planned to mention defonce as a protector of the app-db, but when I tested it I noticed that that part of the demo doesn’t seem to hold. Looking in re-frame.db then, it’s app-db is also just (def app-db (ratom {})) . I just want to understand a bit better how it really works. Even if I realize I should stay away from the subject during the demo. 😃

thheller 2021-04-26T20:58:27.001200Z

well you don't modify the re-frame.db namespace so it is never reloaded and never has this issue

pez 2021-04-26T20:58:41.001700Z

Ah. Thanks!

thheller 2021-04-26T20:58:45.001900Z

if you have this is your main namespaces that is constantly getting reloaded you will lose your state every time without defonce 😉

pez 2021-04-26T21:00:34.003Z

Yeah, I can totally get it to happen with a local atom and such. Which added to my confusion.