garden 2025-10-15

Hello, I've been running into an issue where the generated css produces invalid values around calc expressions (example as test below). Basically, the generated CSS removes the spaces around the arithmetic operators in the calc expression, producing a value that the browser doesn't recognize. The issue is in the use of com.yahoo.platform.yui.compressor.CssCompressor in garden.compression, there are tons of GH issues relating to calc for this project, which appears to be dead (no activity in 6 years). Has anyone investigated this issue before and come up with any leads for potential fixes? Or is anyone privy to a fork of this library that is actively maintained?

(deftest calc-tests
  (is (= ".foo{height:calc(100vh + 10px)}"
         (compile-helper [:.foo {:height "calc(100vh + 10px)"}]))))
;;
expected: (= ".foo{height:calc(100vh + 10px)}" (compile-helper [:.foo {:height "calc(100vh + 10px)"}]))
  actual: (not (= ".foo{height:calc(100vh + 10px)}" ".foo{height:calc(100vh+10px)}"))

Nice! (Just a side note which you maybe knew already, but that's not the original garden, but a fork of it. The original is this one https://github.com/noprompt/garden)

Yeah, I know. From my understanding, noprompt stopped maintaining his Clojure repos. This is the new maintained version of it, right? Or should I be making this PR elsewhere?

This is the new maintained version of it, right? Or should I be making this PR elsewhere?
Uhm, that's a great question indeed! 😄 https://clojurians.slack.com/archives/C0FQERS0H/p1713278364242369?thread_ts=1707378542.124069&cid=C0FQERS0H So is lambdaisland taking over this project and is that the fork the community should start using? In my opinion, it would be awesome if that's the case. 🙏 I'd be happy to see some issues fixes in Garden and happy to contribute. Garden works great already, but there are some things that make it difficult to work with "modern css syntax", e.g. the issues related to whitespace handling in the selectors https://github.com/noprompt/garden/issues/208 and https://github.com/noprompt/garden/issues/187. Would be nice to get those fixed. Pinging @plexus here in case you want to give your opinion about the lambdaisland/garden fork

🙏 1

Because of this exact issue, I'm just compiling with :pretty-print? true and ignore YUI compressor. But I'm building a "admin console" which isn't publicly available and thus isn't preformance critical so not having a compression isn't problem for me. But if you need the CSS to be compressed, I'd still recommend doing compiling garden with YUI compression and adding an additional build step and using some other CSS compressor.

I’ve created a PR to garden that fixes this. https://github.com/lambdaisland/garden/pull/3

👍 1

yeah see the note in the README, we forked it because it had a bunch of unreleased fixes, and we rely on it quite heavily for Ornament. I don't necessarily want to claim that we took over the project or are the official fork or anything like that. I also don't think we're going to invest a lot in Garden specifically because it seems to generally just work for our use cases, but we're happy to accept and release patches as with any of our libs. I'll have a look at your PR @bwancor. Sorry no one has responded yet, sometimes these things fall through the cracks. If you make a PR on a LI project and havent' gotten a reaction after a few weeks you're always welcome to ping me. regarding YUICompressor, we also generally turn compression off because it can cause issues. If there's a drop-in replacement that's better maintained then I'd be happy to switch us, again just drop a PR. I don't think you generally really need it though. CSS gzips well, so it's already quite compact over the wire, and once it's loaded it's generally cached.

🆒 1
🙏 1

@bwancor your two patches have been released

[com.lambdaisland/garden "1.8.601"]
{com.lambdaisland/garden {:mvn/version "1.8.601"}}