Fork me on GitHub
#clojurescript
<
2023-01-11
>
J Crick16:01:36

Greetings! I just tried setting up Tempura for a new re-frame project I'm working on. All seemed well, until I rendered the page in question: > "Runtime resource loading not possible for cljs dictionaries. See tempura/load-resource-at-compile-time as an alternative." I found nothing on Tempura's site about how to load the resource at compile time---and nothing online. Does anyone have any experience with this, and can shed any light on how I can load the dictionary at compile time?

robert-stuttaford16:01:29

i recommend opening an Issue directly on the github project @U01AM3FERS6 - Peter is most responsive there!

ccann18:01:43

Hi, can anyone help me figure out how to pass max and initial heap size to clojurescript builds? we use figwheel main our builds on Jenkins seem to be getting OOMs occasionally and we have plenty of memory on the machine

dnolen18:01:53

@ccann via deps.edn?

ccann18:01:22

can I just use :jvm-opts ?

Rupert (All Street)21:01:08

Looks like there is an env variable https://groups.google.com/g/clojure/c/h3M-LSlE4dw?pli=1.

export LEIN_JVM_OPTS=-Xms4G -Xmx4G

Rupert (All Street)21:01:01

I suspect that by the time lein has read the project.clj file - the Leinn JVM has already started so the options can't be put in project.clj.

thheller06:01:35

lein starts a new jvm for tasks, so :jvm-opts is fine

Rupert (All Street)10:01:00

I think the OOM failure being discussed is during the build inside the lein process itself. @U05224H0W, you are saying that lein process 1 starts another lein process 2 for doing the build task?

thheller10:01:49

yes, otherwise :jvm-opts would make little sense

Rupert (All Street)09:01:57

I thought JVM-opts was only for running the app that is started up (e.g. lein run, lein repl , cider-jack-in etc). Not for all the tasks that lein can do internally within it's own JVM e.g. deps , do , shell, check , install , uberjar etc.

thheller16:01:51

Not all tasks, but I believe the figwheel compilation is one of them.

Asher Serling22:01:36

Hi. I have a luminus project with a re-frame front-end. I want to pass some data directly to the front-end as a javascript object or a json string saved in a var inside a script tag, but when i use the selmer 'safe' tag, the 'window' object no longer has this property. More concretely, I am defining a var user and setting it to a json string. When I do not use the safe tag, I can access this with

(.-user js/window)
But when I do use the safe tag, trying to access it gives me back 'nil'. Why in the world is this? And what can I do about it? Thanks in advance

p-himik05:01:18

Have you tried inspecting the HTML? Also, I wouldn't use a script tag for this or JSON. In such cases, I usually serialize data with Transit, put it in a <script> tag with some ID and a custom type that browsers don't interpret, and deserialize it on the client myself.

Asher Serling05:01:56

when i inspect the html, i find that it is there

Asher Serling05:01:12

can you please show me an example of how you would do it?

p-himik05:01:26

So is it exactly the same as when you do not use the safe tag?

Asher Serling05:01:42

when i view source

Asher Serling05:01:07

if the safe tag is not present, then all quotation marks are replaced with &quot;, but the data is available on 'window'

Asher Serling05:01:29

when i use safe and view source, it looks good, but the data is not available

p-himik05:01:37

> can you please show me an example of how you would do it? I'm not sure what to show. There's just Transit serialization/deserialization code, along with (-> js/document (.getElementById "my-transit-data-or-whatever") .-text).

Asher Serling05:01:11

you said you don't put it in a script tag, but then you said you do put it in a script tag. i'm not sure exactly what you mean

p-himik05:01:00

Ah, right. I meant that I wouldn't use a <script> tag with the default type. I use <script type="text/transit+json">, but that type can be anything that a browser won't interpret.

p-himik05:01:18

> when i use safe and view source, it looks good, but the data is not available There must be something in there. Try with an empty JSON and compare. If you don't see any difference apart from the quotes, upload screenshots of both w/ "safe" and w/o "safe" - maybe I'll notice something or at least will become as surprised as you are. :)

p-himik05:01:26

Well, there's your problem - "{"id":1,"...}" is not a valid string. It's a string "{" followed by a symbol id followed by a string ":1,", and so on. safe embeds your string as is, without any escaping. If your string must be a, well, string, then there must be some escaping. By default, Selmer escapes using HTML entities, but those aren't readable by a JSON parser. No idea what the best solution for this would be. Selmer has a json filter, but it also will be escaped. You can try combining it with safe as in {{user|json|safe}} (of course, here user is the raw data and not a serialized one), but judging by the documentation it'll lead to the same issue. But maybe not, no clue. Alternatively, you can serialize the data to a JSON string yourself, wrap it in single quotes, and use with safe. But as I mentioned, I would just use Transit with a script tag with a custom type. Storing data in js/window is evil.

Asher Serling05:01:03

ok, thanks for the advice, i'll try doing it that way

👍 2
Asher Serling06:01:18

even when it renders like this

Asher Serling06:01:33

it still comes up as nil when i try to access it

p-himik06:01:52

No clue, sorry.

👍 2