Fork me on GitHub
#clojurescript
<
2021-04-12
>
bastilla10:04:32

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.)

bastilla11:04:55

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.

šŸ‘ 3
ā¤ļø 2
prnc14:04:29

Hi šŸ‘‹ Just starting out with transit. In cljs what is a correct way of handling uris? I.e. clj backend sends .Uri as transit, be default itā€™s read as "[TaggedValue: r, ]" 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?

Old account14:04:10

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...

raspasov15:04:27

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

3
p-himik16:04:54

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

šŸ’Ŗ 3
šŸ‘ 2
athomasoriginal00:04:53

For how browser routing works at a low level I highly recommend JS talks by any of the people who wrote the big JS routing libraries. They will explain the problem space context nicely. Then come back to cljs land with that knowledge and take a look at reitit and secretary to see how they handle the problem.

athomasoriginal00:04:12

Note that you don't need secretary to use reitit. I highlight those as libraries which are solving similar problem in different ways

Old account05:04:01

@U6GNVEWQG Could you please recommend some library like that? I am new in this...

athomasoriginal12:04:51

react-router, vue-router etc

šŸ’Ŗ 2
raspasov14:04:46

I keep forgettingā€¦ is something like this considered ā€œsafeā€ under :advanced or should we explicitly add an extern for it?

#js {:opacity 0}

raspasov14:04:07

As in, the :opacity wonā€™t magically turn into an ā€˜oXā€™ or something šŸ˜„

raspasov15:04:14

(I think itā€™s safe but I thought I saw a discussion at some point about certain gotchas around interop, I could be mistaken)

thheller15:04:43

it can be renamed if there are not externs

thheller15:04:55

but there are externs for opacity so its safe

p-himik15:04:12

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?

thheller15:04:02

not actually sure

raspasov15:04:35

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

raspasov15:04:45

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) ?

raspasov15:04:42

(defn props-class ā€œGet props for class componentsā€ [^js/Object this] (.. this -props -_cljs))

raspasov15:04:07

Because of the hinting.

p-himik15:04:18

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.

šŸ‘ 3
pinkfrog15:04:02

From the doc, it seems to me re-frame-10x doesnā€™t work with along react native. Is that the case?

p-himik16:04:05

#re-frame would be a more suitable place.

Jack Arrington16:04:09

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?

p-himik16:04:45

Just a stylistic thing. Brackets are generally more often recommended.

šŸ‘ 3
lilactown17:04:38

does anyone have a snippet to start a node REPL outside of a project?

djblue17:04:59

Like with nrepl or just a plain cljs repl?

lilactown17:04:45

just a plain CLJS repl is fine

lilactown17:04:49

from my terminal

djblue17:04:49

clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.844"}}}' \
    -m cljs.main -re node

lilactown17:04:26

šŸ˜ that is incredibly close to what I've been attempting

lilactown17:04:50

yours works tho šŸ˜„

lilactown17:04:59

tyvm

šŸ’Æ 3
p-himik17:04:59

Similar:

clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -M -m cljs.repl.node

djblue17:04:03

That's weird, they look identical lol

thheller17:04:16

the :deps map is missing šŸ˜‰

šŸ‘Œ 3
djblue17:04:32

Well there it is šŸ‘Œ

thheller18:04:24

clj -Sdeps '{:deps {thheller/shadow-cljs$aot {:mvn/version "RELEASE"}}}' -M -m shadow.cljs.devtools.cli node-repl šŸ˜‰

djblue18:04:52

Wait... is $ how you specify a classifier?

thheller18:04:53

will break horribly though since npm packages are missing šŸ˜‰

lilactown18:04:05

I'm trying to report a CLJS bug so I want to keep it minimal

šŸ‘€ 3
p-himik18:04:37

Used to work with Java directly, but learned about Maven classifiers via a question about CLJS REPL. :D

lilactown17:04:58

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