clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
bastilla 2021-04-12T10:51:32.109300Z

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

bastilla 2021-04-12T11:06:55.109800Z

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.

👍 1
❤️ 1
prnc 2021-04-12T14:51:29.114200Z

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?

Audrius 2021-04-12T14:57:10.115400Z

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

athomasoriginal 2021-04-13T12:07:51.141Z

react-router, vue-router etc

💪 1
raspasov 2021-04-12T14:57:46.116100Z

I keep forgetting… is something like this considered “safe” under :advanced or should we explicitly add an extern for it?

#js {:opacity 0}

raspasov 2021-04-12T14:59:07.116200Z

As in, the :opacity won’t magically turn into an ‘oX’ or something 😄

raspasov 2021-04-12T15:00:14.116400Z

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

raspasov 2021-04-12T15:06:27.116500Z

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

1
thheller 2021-04-12T15:13:43.116900Z

it can be renamed if there are not externs

thheller 2021-04-12T15:13:55.117100Z

but there are externs for opacity so its safe

p-himik 2021-04-12T15:22:12.117300Z

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?

2021-04-12T15:23:02.117900Z

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

thheller 2021-04-12T15:25:02.118Z

not actually sure

raspasov 2021-04-12T15:33:35.118200Z

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

raspasov 2021-04-12T15:34:45.118500Z

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

raspasov 2021-04-12T15:35:26.118700Z

Aha! And because I have this… https://github.com/raspasov/alexandria-clj/blob/main/src/ss/react/core.cljs#L95 It’s safe…

raspasov 2021-04-12T15:35:42.119100Z

(defn props-class “Get props for class components” [^js/Object this] (.. this -props -_cljs))

raspasov 2021-04-12T15:36:07.119300Z

Because of the hinting.

p-himik 2021-04-12T15:37:18.119500Z

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.

👍 1
p-himik 2021-04-12T16:38:05.121100Z

#re-frame would be a more suitable place.

Jack Arrington 2021-04-12T16:38:09.121400Z

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-himik 2021-04-12T16:38:45.121600Z

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

👍 1
p-himik 2021-04-12T16:39:54.121800Z

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

👍 1
💪 1
lilactown 2021-04-12T17:50:38.122500Z

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

lilactown 2021-04-12T17:50:58.123100Z

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

djblue 2021-04-12T17:56:59.123200Z

Like with nrepl or just a plain cljs repl?

lilactown 2021-04-12T17:57:45.123500Z

just a plain CLJS repl is fine

lilactown 2021-04-12T17:57:49.123700Z

from my terminal

djblue 2021-04-12T17:57:49.123900Z

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

lilactown 2021-04-12T17:58:26.124100Z

😐 that is incredibly close to what I've been attempting

lilactown 2021-04-12T17:58:50.124600Z

yours works tho 😄

lilactown 2021-04-12T17:58:59.124800Z

tyvm

💯 1
p-himik 2021-04-12T17:58:59.125Z

Similar:

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

djblue 2021-04-12T17:59:03.125200Z

That's weird, they look identical lol

thheller 2021-04-12T17:59:16.125500Z

the :deps map is missing 😉

👌 1
lilactown 2021-04-12T17:59:32.125700Z

omfg

djblue 2021-04-12T17:59:32.125900Z

Well there it is 👌

thheller 2021-04-12T18:00:24.126200Z

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

djblue 2021-04-12T18:00:52.126400Z

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

thheller 2021-04-12T18:00:53.126600Z

will break horribly though since npm packages are missing 😉

lilactown 2021-04-12T18:00:57.126800Z

lol

thheller 2021-04-12T18:00:58.127Z

yes

1
lilactown 2021-04-12T18:01:05.127200Z

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

👀 1
p-himik 2021-04-12T18:02:37.127600Z

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