Hi there. I am pretty sure you pros can answer this. Regarding electron, this is about the project.clj :externs
mechanism. I successfully wrote and prod-build an electron app. Next step was: using nodejs functions (to access local files, etc.) All of a sudden, my app's prod build doesn't run any longer. Electron comes up, blanks, and Console tells me:
Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value).Xd is not a function at xr (helper.cljs:24
And that particular line is using nodejs:
(let [fs (nodejs/require "fs")] (.writeFile fs location content "utf8" err-report)))
So I figured, the :optimizations :advanced
build disconnects code from library. If my assumption is correct, how can I include nodejs? (via externs) I'd also appreciate a link (couldn't find something helpful so far). Thanks!
(Sry for using this channel. #electron seems to be dead.)
aaaand as so often, right after posting a question, I stumple over a solution. Just adding
:dependencies [cljsjs/nodejs-externs "1.0.4-1"]
is one solution. Sorry! And thanks for just being there. This is an awesome community.
Hi 👋
Just starting out with transit. In cljs what is a correct way of handling uris? I.e. clj backend sends <http://java.net|java.net>.Uri
as transit, be default it’s read as "[TaggedValue: r, <http://google.com>]"
tagged value, what’s the recommended way of getting str
out of that? just asking for .-rep
field? what’s a good way to config the reader to do it automatically?
Hello, I am searching for info how does browser routing work. Like Reagent router or Reitit frontend. I want to understand on how does it work with browser in low level...
react-router, vue-router etc
I keep forgetting… is something like this considered “safe” under :advanced or should we explicitly add an extern for it?
#js {:opacity 0}
As in, the :opacity won’t magically turn into an ‘oX’ or something 😄
(I think it’s safe but I thought I saw a discussion at some point about certain gotchas around interop, I could be mistaken)
I have personally never been a fan of most routing framework approaches; IMO they make things way too complicated for what they provide; If you want “routing”, it doesn’t take much to set it up yourself based on, say, anchor hash value https://www.w3schools.com/jsref/prop_anchor_hash.asp ; now if you want to parse parameters, etc, etc you might want to consider a library
it can be renamed if there are not externs
but there are externs for opacity
so its safe
If it's some name that doesn't have an extern, how to prevent it from being mangled, without having to write explicit externs? Is there a way to do it with ^js
?
From the doc, it seems to me re-frame-10x doesn’t work with along react native. Is that the case?
not actually sure
Hmm so if it’s a custom name, unlike :opacity, it’s not considered safe?
So something like https://github.com/raspasov/alexandria-clj/blob/main/src/ss/react/core.cljs#L63 would not be safe? :_cljs
At the same time, I’ve been compiling this for a long time with :advanced and not run into problems… I guess it might be a problem if you try to access it like (.-_cljs my-js-obj) ?
Aha! And because I have this… https://github.com/raspasov/alexandria-clj/blob/main/src/ss/react/core.cljs#L95 It’s safe…
(defn props-class “Get props for class components” [^js/Object this] (.. this -props -_cljs))
Because of the hinting.
Yeah, maybe something like
(defn ^:export -dummy [^js x]
(.-_cljs x))
would work. It can even be used to "externalize" multiple properties, in case you don't use them anywhere else in the CLJS code.#re-frame would be a more suitable place.
Is there any advantage of doing :refer [thing1 thing2]
over :refer (thing1 thing)
inside the ns
form, or does it not make a difference either way?
Just a stylistic thing. Brackets are generally more often recommended.
Modern browsers can help avoid using hash fragments and just use regular URL path for that. This is the API: https://developer.mozilla.org/en-US/docs/Web/API/History_API
does anyone have a snippet to start a node REPL outside of a project?
it feels like I should be able to do this with some alias or combination of CLI opts but the documentation is so spread out I'm struggling
Like with nrepl or just a plain cljs repl?
just a plain CLJS repl is fine
from my terminal
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.844"}}}' \
-m cljs.main -re node
😐 that is incredibly close to what I've been attempting
https://clojurians.slack.com/archives/C6QH853H8/p1618250174465300
yours works tho 😄
tyvm
Similar:
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -M -m cljs.repl.node
That's weird, they look identical lol
the :deps
map is missing 😉
omfg
Well there it is 👌
clj -Sdeps '{:deps {thheller/shadow-cljs$aot {:mvn/version "RELEASE"}}}' -M -m shadow.cljs.devtools.cli node-repl
😉
Wait... is $ how you specify a classifier?
will break horribly though since npm packages are missing 😉
lol
yes
I'm trying to report a CLJS bug so I want to keep it minimal
Used to work with Java directly, but learned about Maven classifiers via a question about CLJS REPL. :D
https://gist.github.com/raspasov/978ccb338e4b8c56513c10d3523877c7