Fork me on GitHub
#announcements
<
2023-12-02
>
mauricio.szabo01:12:20

Once, I complained that things like Solid.JS with ClojureScript might be close to impossible, because ClojureScript is "outside" the way JS works (with Babel, bundlers, etc). I decided to explore if I could make some elaborate hack to support at least Babel. And... here it is: I called it Babble https://gitlab.com/mauricioszabo/babble. It does have some very primitive support for SolidJS, now I have to battle-test in a real... something. Not sure yet what I will build 😄

👏 5
🎉 4
clojure-spin 1
🚀 1
Chase02:12:15

This seems cool. Just to clarify, you are working on your own compiler tool like Babel that can do similar things like solidjs (or svelte?) does where it compiles your own custom built features written in cljs (like your version of signals or jsx or whatever) into javascript? so at a lower level than something like a solidjs wrapper (https://github.com/roman01la/solid-cljs and others mentioned here: https://www.reddit.com/r/Clojure/comments/10ywila/clojurescript_bindings_to_solidjs/) so that those bindings wouldn't be needed, you could just build out the cljs version of solidjs yourself?

Chase02:12:21

I think your readme means to say "Like Babel, but for ClojureScript" instead of reiterating the "Babbel" name

borkdude07:12:11

Nice hack :) For anyone looking for alternatives, solid-js is pretty easy with #squint and #cherry since they can transform to jsx: https://github.com/squint-cljs/squint/blob/main/examples/solid-js/src/App.cljs

borkdude07:12:48

@U3Y18N0UC Perhaps it's worth exploring to use GraalVM Polyglot, they support JS too. Don't know how Node specific the babel stuff is that you're using but if it can run in GraalJS, might be worth trying

borkdude07:12:36

You don't even need GraalVM anymore to run GraalJS, it can run on any JVM

👀 1
mauricio.szabo13:12:27

So, @U9J50BY4C - it's literally Babel - I'm not working in a different compiler. The trick is to run Babel while we're in Java-land, and to make it work correctly while we need to interpolate ClojureScript variables, and to work in string fragments instead of full files.

mauricio.szabo13:12:12

And yes, Babel is very node-specific - it uses require and NPM stuff and resolves that in runtime, so I indeed need node - only GraalJS won't work (but I found a different lib that works and is maintained too)

borkdude13:12:56

I'm going to add support in squint for compiling jsx straight to react calls too since that would be better for the browser REPL

mauricio.szabo17:12:17

Yes, I basically did the hack because I use a lot the Shadow-CLJS "hot reload" and the REPL. There are other solutions to fix this problem with Babel - like generating a JSX "by hand", compile the project via Shadow with the ESM target, and then run babel on top of it - maybe even add a Shadow-CLJS hook for it. With the hook, it almost worked - but I lost the hot-reload because Shadow sends the JSX, pre-babel version to the browser (I need to refresh the page to actually work).