cherry

amano 2025-07-04T14:42:13.295609Z

How ready is cherry now for web development?

borkdude 2025-07-04T18:15:12.353389Z

The compiler is pretty stable now. There is no squint.edn for cherry yet and cherry doesn't have watchi functionality yet (might be easy to port it over from squint though).

borkdude 2025-07-04T18:15:49.716879Z

for web dev there isn't a REPL yet, although I do have a REPL in the playground. the compiler is able to generate REPL-compliant code, but the plumbing to make it work in a browser via nREPL hasn't been done

f2wHTttf 2025-07-04T19:05:16.668979Z

I think REPL might be slightly less of a concern for frontend web dev since the typical workflow is to do live preview (e.g. vite dev). For that, Squint has https://github.com/brandonstubbs/vite-plugin-squint which can probably be cloned to create a vite-plugin-cherry so incremental Cherry compile + hot module reload (HMR) is triggered whenever a .cljs file is updated.

f2wHTttf 2025-07-04T19:13:49.551899Z

Wait nevermind, vite-plugin-squint doesn't support HMR yet. Looks like the to-do list in the README might be wrong. There's a handleHotUpdate handler.

borkdude 2025-07-04T19:15:10.392439Z

I don't use any plugin myself. The compilation model of squint and cherry is simple. Whenever a file changes, you can re-compile it using a watcher. Then the JS tooling can pick up on the compiled JS.

amano 2025-07-05T03:03:03.038149Z

Can I use re-frame, reagent, and UIx with cherry as I can with clojurescript? Can I use cherry stack in production?

amano 2025-07-06T13:03:29.846679Z

Damn. You found a use case for cherry in production, but that looks complicated. People were driven away from clojurscript by build complexity.

amano 2025-07-06T13:24:33.238409Z

Borkdude, your example seems deceptively simple.

borkdude 2025-07-06T13:48:59.536479Z

If you want to avoid builds #scittle might be interesting but otherwise you always have some build stuff unless you use plain JS

f2wHTttf 2025-07-06T17:17:28.158339Z

Once Cherry/Squint supports enough Clojure features for Closure-library-free CLJS libraries to "just work", you can remove CLJS from the equation (ignoring dead code elimination parity between the Closure compiler and JS tree-shakers). For the time being, however, you need to do this kind of stitching if you want to use CLJS libraries. If you just need a small glue layer to stitch JavaScript libraries together with Clojure syntax, you can use just Cherry/Squint standalone.

wcohen 2025-07-17T19:28:24.754949Z

My other observation today is that it appears that these problems of having to manually enumerate go away if everything is in the same directory. My workaround at the moment is to just stop having impl and other subdirectories, as unideal as that may be.

wcohen 2025-07-17T19:28:54.942869Z

I'm not doing frontend work, so at the moment, esbuild is likely my goto rather than vite.

borkdude 2025-07-17T19:40:41.128349Z

yeah cherry is more limited than squint, since we don't have a cherry.edn config file, it assumes stuff to be in either src or the root dir

wcohen 2025-07-17T19:42:06.125539Z

Working with it more it makes sense — if the NPM/JSish method is to esbuild it all up at the end for a dist/ version, if it can’t all fit in one big directory, maybe it’s time for a second package at that point.

wcohen 2025-07-17T19:42:18.226289Z

Different than a big jar

wcohen 2025-07-15T19:59:24.563789Z

Still working through it, but this seems like it may work in terms of referring across different namespaces in package.json — compile each one with npx cherry other_cherry_ns.cljs, then re-reference them so the modules resolve correctly. “exports”: { “.”: “./main_cherry_export_namespace.mjs”, “./foo.bar.other-cherry-ns”: “./impl/other_cherry_ns.mjs”, “./yet.another.cherry-ns”: “./impl/yet_another.mjs” },

f2wHTttf 2025-07-16T05:14:53.077579Z

Manually enumerating all namespaces as export entrypoints in package.json sounds pretty painful.

f2wHTttf 2025-07-16T05:22:28.614039Z

If you're using Vite or Rollup, you're better off having a plugin like vite-plugin-squint which hooks into Vite/Rollup's import processing hooks. There's basically 2 hooks they expose: 1. resolveId a. Transforms an import "{id}" ESM import statement. For example, a plugin can turn every import "{namespace}.cljs" statement into import "{absolute CLJS file path}.cljs.js". 2. load a. Returns the contents for a given resolved ID. For example, it can match on *.cljs.js files, strip off the trailing .js to find the absolute path of the source CLJS file, invoke Squint/Cherry's compileString method, and return the compiled result. This is effectively what vite-plugin-squint does (though it always compiles to .cljs.jsx files instead because JSX is a superset of JS). https://github.com/brandonstubbs/vite-plugin-squint/blob/main/index.mjs The handleHotUpdate hook is specific to Vite for hot module replacement (HMR).

f2wHTttf 2025-07-16T05:30:04.332719Z

With vite-plugin-squint, you can import a CLJS file directly in a :require statement and it just works. https://github.com/brandonstubbs/vite-plugin-squint/blob/0f932fb72da83e1e93ffc39bdef9d7c7a6d7d37c/demo/react/src/main.cljs#L4

f2wHTttf 2025-07-05T07:52:32.578599Z

I don't think so since neither Cherry nor Squint support user namespace requires yet so you can't import the re-frame, reagent, or UIx namespaces. https://github.com/squint-cljs/cherry/issues/64 There's also other missing features like multimethods. https://github.com/squint-cljs/cherry/issues/35

borkdude 2025-07-05T08:03:20.859999Z

user namespaces are supported in squint if you use a squint.edn file. but dependencies from clojars aren't directly supported and indeed, there are some differences. So when it comes to CLJS compatibility you're just better off with regular CLJS.

👍 1
borkdude 2025-07-05T08:04:10.052519Z

another differences is that there is no goog.*

amano 2025-07-05T09:19:38.254289Z

Because cherry doesn't support user namespaces that come from cherry libraries, I guess it's far from being ready for production.

borkdude 2025-07-05T09:21:12.462909Z

You can refer to other compiled JS files like any other JS library

borkdude 2025-07-05T09:21:29.659889Z

So you technically don’t need to refer to “namespaces”

amano 2025-07-05T09:22:00.656199Z

Can you show me a minimal example of referring to compiled JS files?

borkdude 2025-07-05T09:29:14.655929Z

There might an example in the examples dir. I’m not at a computer right now but will come back at this later

f2wHTttf 2025-07-05T17:56:19.107089Z

Depending on your frontend library stack of choice, you'll either use: • Pure CLJS ◦ Typically with shadow-cljs for its better Node.js package interop configs. • CLJS + Cherry/Squint ◦ CLJS for Clojure libraries that need CLJS's full feature set. ◦ Cherry/Squint for interfacing with Node.js packages that don't play nice with the Closure compiler or for hooking into JS build tools like Vite. ▪︎ Many frontend frameworks have their own custom template formats (e.g. .jsx, .vue, .svelte) which CLJS can't output. ▪︎ Cherry/Squint, however, can output .jsx with its #jsx literal so with a Vite plugin, this can seamlessly integrate with JSX-based frameworks like Solid.js, React, and Preact. ◦ For live reload in both halves of the chain (CLJS via shadow-cljs + Vite), you would do: ▪︎ CLJS • Configure shadow-cljs to output to a well-known directory (e.g. ./generated). • shadow-cljs watch ▪︎ Vite • Configure a Vite alias to point to the shadow-cljs output directory (e.g. $generated./generated) so you can do import '$generated/{cljs output}.js' (for JS files) or (:require ["$generated/{cljs output}.js"]) (for Cherry/Squint files) in files under Vite's purview. • vite dev

👍 1
markaddleman 2025-07-04T22:04:48.906549Z

In a wild dream, I’m thinking that I could author BigQuery UDFs (which are natively Javascript) in Cherry assuming I can load the standard library from a Google storage bucket. Has anyone tried this? Is there some reason it wouldn’t work?

borkdude 2025-07-05T15:49:41.333099Z

I don't see why not. Just compile the thing and put it on GS? I found a maybe related article. It mentions webpack but I think I'd use vite nowadays https://medium.com/swlh/how-to-package-a-javascript-library-for-use-in-bigquery-2bf91061f66f

markaddleman 2025-07-05T16:46:34.764299Z

thanks! I’ll take a look