Fork me on GitHub

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


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


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


@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


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

@UEJ5FMR6K I'd recommend writing Google closure modules.

👍 3
✔️ 3

Then they can just be required from cljs like normal.


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


Helix has an example


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?


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


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


@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


Hashing to a uuid format, yes


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?


if your function is available globally, just put the name


i'd assume


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


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


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


kinda hacky, but simplifies my serverside rendering approach


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, yet shadow-cljs watch keeps erroring with: The required namespace "" is not available.


change folder name from chrome-ext to chrome_ext

💯 3

oh crap. ofc


any clojurescript projects supporting gitpod ( yet? would be neat to see a typical emacs/cider/figwheel project on gitpod...


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


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.


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.


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


how can I indicate a parent element with cljs?


.-parentElement seems to work actually 🙂


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


getting strange nesting behavior