Fork me on GitHub
#shadow-cljs
<
2021-02-06
>
Peter Muys05:02:29

@thheller Thank you for your help yesterday!

👍 3
Karol Wójcik10:02:49

How to set polyfills for ResizeObserver in shadow-cljs? Or maybe in general how do you include polyfills?

thheller10:02:12

not sure there are any for ResizeObserver in closure. you can always use https://polyfill.io/v3/ separately

Adam Helins14:02:25

Looking at the doc I don't think so, but is it possible to add metadata to a namespace to prevent caching? :cache-blockers works but it's not very user-friendly when it comes to libraries

thheller14:02:38

why would you want that? there is ^:dev/always

Adam Helins18:02:16

@thheller Once again I was in a bit of an odd situation... I am messing a lot with doing side effects at compilation these days. Being able to force compilation from metadata might be a useful feature given how Shadow-CLJS is widely used. You wouldn't have to add defaults in :cache-blockers but then it's true that side-effecting on compilation is definitely not a widespread habit

thheller19:02:01

its also a bad idea. if you share what you are working on I can maybe make some suggestions.

Adam Helins19:02:41

It's a somewhat novel CSS compiler that does many things. Essentially, this bit is about Garden rules declared in CLJC files being recompiled from Clojure (JVM) everytime a file is saved, which also triggers CLJS recompilation and does some syncing between those 2 environments. It works really well actually but there are a few problems that are tough to solve in order to provide a seamless experience. Slowly getting there 🙂 I'll let you know when I release an alpha version

Adam Helins19:02:53

But those problems are very specific and definitely not the kind of day to day work a Clojurist does, that's why I have been asking weird questions around a few channels lately :p

West20:02:50

@adam678 Yo, I’m really interested in this CSS compiler. What are some other things it can do?

Adam Helins20:02:40

@c.westrom It leverages Garden but provides a whole dev experience as well as aggressive optimizations for production. In dev mode, it is about providing structure, documentation, and efficient live reloading. All names such as CSS classes are defined in an Clojure idiomatic way as Vars. Easy to consume, can hold docstrings, and even more importantly, this prevents any name collision. Any sets of CSS rules you write can be documented as well and when you hit save, are written to files in a two level directory tree mimicking your code (namespace > sym). Everything is always clear in code and you can always see the exact CSS it produces. Only rules that change are recompiled and live reloaded which doesn't put a burden on your dev environment. (The "recompile everything" at save is horrible for any real-world project). In release mode, it provides dead code elimination of CSS by detecting CSS names that survived advanced compilation and analyzing your rules. Then it will actually optimize everything and rewrite your classes! This is extra nice because you don't have to worry about efficiency. When I write rules for a class, everything is flat. I merge maps, don't care at all about CSS inheritance or whatever. It looks like common Clojure. It's the compiler's job to then detect common rules amongst classes, split and merge them as needed, create atomic rules and all those CSS buzzwords. That's it in a gist 🙂

Adam Helins20:02:21

And there is actually plenty more, it can lint your rules at dev time (eg. warn you if there is a typo in a property), warn you if your code uses CSS names which do not show up in your rules, and so one...

West20:02:56

See the reason I asked is I’m working on something myself. I’m trying to use a java-based css parser to convert a CSS file and create garden syntax from it. The experience of trying to integrate npm, shadow-cljs, and all these crazy build steps just to use tailwind, has been pretty crusty.

Adam Helins20:02:52

A parser that supports all CSS is probably not that easy. The end goal is to not need frameworks like Tailwind or Tachyons. Anyway, as soon as you need something they don't provide, you are on your own... I don't believe they are that good of a solution

West20:02:31

True. Tailwind was nice to start though. I really enjoyed putting a class in my HTML and immediately seeing a change. Even better that I can take a reagent component and all my styles stay with it. I would love to implement something like this using hiccup syntax, maybe leverage https://github.com/Jarzka/stylefy. How would you recommend handling CSS using nothing but hiccups?

thheller20:02:35

I wrote https://github.com/thheller/shadow/wiki/shadow.markup a long time ago. sounds somewhat similar.

Adam Helins20:02:12

What I dislike about those solutions is that they are dynamic for things that should be static. It's another way of putting strain on JS. Everything is "blazing fast" in isolation but put together... That's why the web is slow 😛

Adam Helins20:02:58

I have exactly 0 runtime cost here and it's highly optimized... which I like!

thheller21:02:35

it isn't dynamic.

thheller21:02:18

but the thing I never bothered to write but all of this supports is extracting the css in a separate compile phase

thheller21:02:19

anyways .. I'm not using it anymore either so wouldn't recommend anyone else to do it either.

West21:02:51

@adam678 I wanna build static sites using ClojureScript, mostly because I could imagine templating would be easier using functions. I wanna have a multilingual site, also have dark mode/light mode as an option. Either way, can’t wait to see you release this.

👍 3