Fork me on GitHub
#clojurescript
<
2020-06-17
>
victorb07:06:45

I got a project where there is an existing clojurescript codebase (made with figwheel-main, reagent and re-frame) where the company now wants to try to move to something else than clojurescript. And for this migration phase, they would like to be able to either write components in vanilla JS and use them from the existing clojurescript codebase, or have a application in vanilla JS and use the existing clojurescript components in there. I have some ideas on how this could be possible, but wondering if anyone has any examples of this being done in the wild? Would love to see any existing implementations of this done before

Daniel Tan07:06:53

sounds like what cljsjs has done

victorb07:06:49

yeah, that would be "publishing" the vanilla js components somewhere, and import them as foreign lib into the cljs app

raspasov07:06:11

@UEJ5FMR6K curious what’s the rationale for “trying to move to something else than CLJS”?

victorb08:06:51

@U050KSS8M me too! I got as far as the developer who initially built the frontend and knows cljs is leaving the company, and none of the devs who will continue working there wants to learn cljs

raspasov08:06:03

I see… well I guess the thing to research would be “calling ClojureScript from JavaScript” and/or “calling JavaScript from ClojureScript”; I’m not an expert in either, but my gut feeling is that the latter would be somewhat easier (since it’s more or less common to use JavaScript libs from ClojureScript)

👍 3
dominicm11:06:15

@UEJ5FMR6K I'd recommend writing Google closure modules.

👍 3
✔️ 3
dominicm11:06:39

Then they can just be required from cljs like normal.

victorb11:06:23

interesting. Thanks for that! Will take a look at it

dominicm14:06:54

Helix has an example

pmooser09:06:31

So if I am working in cljs in a namespace called foo, and I want to define a macro that I use from foo, is that possible from foo.cljc, or does it have to be in some non-foo namespace?

pmooser09:06:20

Ok, it looks like yes, if I :refer them from the :require-macros form.

danielstockton09:06:16

Does anyone have a helper function for generating a uuid from a string (any string)?

Daniel Tan09:06:42

there’s one already in core cljs

danielstockton10:06:22

@U01458A7CBX I mean like (uuid "my string") that returns a consistent result from a hash that is unique

Daniel Tan10:06:04

oh you mean hashing

Daniel Tan10:06:53

you can use javascript hashing functions as well

danielstockton10:06:34

Hashing to a uuid format, yes

sova-soars-the-sora15:06:02

Hello, my serverside clojure is using rum to generate an html page... how can i include a reference to a vanilla js function in the on-click event?

dazld15:06:23

if your function is available globally, just put the name

dazld15:06:34

i'd assume

dazld15:06:08

should get rendered as a string attribute to html..?

sova-soars-the-sora15:06:18

probably a string! yes... thanks... hmm

sova-soars-the-sora15:06:46

Aha. Thanks. Had me puzzled for a minute. {:on-click (str "promote2question();")}

sova-soars-the-sora15:06:11

kinda hacky, but simplifies my serverside rendering approach

erik15:06:45

in my shadow-cljs.edn I have :source-paths ["src/main"} and the file src/main/com/uxo/chrome-ext/background.cljs has this ns decl: (ns com.uxo.chrome-ext.background), yet shadow-cljs watch keeps erroring with: The required namespace "com.uxo.chrome-ext.background" is not available.

3
Vishal Gautam15:06:16

change folder name from chrome-ext to chrome_ext

💯 3
erik15:06:42

oh crap. ofc

johanatan17:06:42

any clojurescript projects supporting gitpod (https://www.gitpod.io/blog/gitpodify/) yet? would be neat to see a typical emacs/cider/figwheel project on gitpod...

johanatan17:06:02

(in fact, getting cljs stuff on gitpod would lower the barrier to entry dramatically and remove one of the biggest stumbling blocks for new folks coming in to the language)

dominicm19:06:44

I don't think it would dramatically reduce the barrier to entry. The JVM is one of the best contained machines in the world. Most libraries requiring native bindings ship a jar containing what you need in a magic way. You literally install the JVM and you're good to go.

johanatan23:06:12

no, i think you're missing a lot of the development environment setup (emacs, cider, etc etc) here. and psst, this is #clojurescript , not #clojure it sounds like you don't really yet understand what gitpod actually is. i'd suggest reading up on it.

dominicm07:06:58

There isn't a development environment. My development environment doesn't live in the library, and has no place there.

johanatan02:02:49

i have a development environment. not sure why you do not have one.

johanatan02:02:13

not sure also what you mean by "library" but i'd be inclined to agree that a development environment doesn't belong there

sova-soars-the-sora19:06:13

how can I indicate a parent element with cljs?

sova-soars-the-sora19:06:41

.-parentElement seems to work actually 🙂

sova-soars-the-sora19:06:04

so I'm using rum to hydrate a component, but i think i need to tell rum/hydrate the parent component so it knows how to find it... it would seem

sova-soars-the-sora19:06:13

getting strange nesting behavior