Fork me on GitHub
#shadow-cljs
<
2019-05-26
>
Stefan13:05:30

Can I use “static image loading” (https://facebook.github.io/react-native/docs/images.html) also from ClojureScript when using shadow-cljs? That would be including the automatically loading of @2x and @3x variants… Second question: How could I have found the answer to the first question myself? I couldn’t find the answer by web searching and searching in ClojureVerse and Zulip… 😞

orestis14:05:50

Not uncommon for people not to talk about stuff like that - so you’re not doing anything wrong! Asking here or on ClojureVerse (or reddit, or indeed everywhere) is usually a good idea.

orestis14:05:10

(Two negations, sorry!)

orestis14:05:58

Since you’re talking about react native I’d look around for the relevant channels too. It’s a smaller community that does react native with ClojureScript...

Stefan18:05:07

Thanks guys! I was told that this community is very supportive, but it still amazes me how much that is true! @thheller That worked. The relative path starting with ‘..’ was the missing part, didn’t occur to me to try it that way.

jimmy18:05:59

I’m having some trouble with a bootstrapped web worker. I’ve made a minimal reproducible case. Here it is hosted (check the console). https://shadow-bug.jimmyhmiller.now.sh/ and here is the source https://github.com/jimmyhmiller/PlayGround/tree/529f7276139574a7b34066c501f9b17dd8f5efca/shadow-debug The worker is getting a document not defined error. It appears that this is the culprit. https://github.com/thheller/shadow-cljs/blob/d93af50a6b5e54553762ab273102a3cd16139b6d/src/main/shadow/cljs/bootstrap/browser.cljs#L37-L43 If I change this to use js/eval everything works. Do I have some configuration wrong or is this a bug when trying to do bootstrapped web workers?

thheller19:05:38

@jimmy that code assumes it is running in a normal browser context. webworkers should probably have their own version but if it works I'd be fine to change that

thheller19:05:50

should be (js/goog.globalEval ...) though

jimmy19:05:23

@thheller The doc string says it is for optimization purposes. I’m happy to make a PR changing it to js/goog.globalEval, but want to make sure it isn’t going to cause any performance regressions. Any benchmarks I need to run as part of the PR?

thheller19:05:07

(js/eval ...) never gets JIT optimized so it runs substantially slower. js/goog.globalEval should be ok

👍 1
thheller19:05:43

please put the file into your classpath first

thheller19:05:03

and actually run it since I have no setup to verify that it actually works as intended in a webworker after that

thheller19:05:24

well I guess I do since you made the repo

jimmy19:05:13

Not sure I will get around to it today. But I will definitely make sure things are working in the browser and in the web worker before submitting.

jimmy19:05:12

Thanks for the quick help and great project