thheller / shadow-css

CSS-in-CLJ(S)
https://github.com/thheller/shadow-css
Eclipse Public License 1.0
108 stars 10 forks source link

Doesn't handle multiple files with same namespace #24

Open raystubbs opened 7 months ago

raystubbs commented 7 months ago

I have an icons.clj with a macro for generating icon markup, and an icon.cljs with :require-macros. The CSS for icons.clj never gets generated. It looks like multiple files with the same ns will override each other. image

thheller commented 7 months ago

Hmm right, not something I considered. Will think about it.

thheller commented 7 months ago

This is a surprisingly difficult thing to get right. While it won't be common it is absolutely possible to have both files use a (css ..) form in the exact same spot. That would lead to a conflict, since all that is considered for the generated classname is the ns, line and column.

So, maybe the generation needs to consider whether it is a CLJ or CLJS context, which then becomes tricky for CLJC since thats often both at the same time.

Will think about it some more ...

thheller commented 7 months ago

FWIW one possible fix is using a .cljc file instead of two separate files. Not something I usually recommend but reasonable for this case.

raystubbs commented 7 months ago

Huh, hadn't thought of that. Good idea.

philjackson commented 5 months ago

@thheller Could shadow-css work on files rather than namespaces?

thheller commented 5 months ago

Maybe. See my comment from above.

My first attempt at fixing this issue was exactly that. Ran into quite a few quirks, so ultimately shelved it. One of the limiting things being that its not always easy to get the filename in the macro context (for example stuff eval'd at the REPL).

Didn't have too much time to think about this yet.