- From: Romain Menke via GitHub <sysbot+gh@w3.org>
- Date: Tue, 02 Jul 2024 06:33:48 +0000
- To: public-css-archive@w3.org
Although I am sympathetic to the challenges and issues I don't think that having an equivalent of JS modules in CSS would be a good thing. (1) Having multiple ways CSS can behave depending on "is a module" vs "is not a module" is bad on its own. This makes everything more complex to use and understand. This is not a short term pain. Such a CSS modules system would not be successor to what exists today. We would be stuck with two parallel mental models indefinitely. (2) Naming conflicts are a real issue, let's solve that specifically. You should be able to handle naming conflicts without needing to switch to a radically different way CSS is applied. Making the ability to handle naming conflicts exclusive to CSS modules wouldn't help all CSS authors. (3) With cascade layers we already have a tool to determine the order in which CSS is applied. Being able to determine the order makes it possible to solve most issues that could happen by having multiple imports of the same file. (4) Existing tooling to simulate isolation of styles is very invasive. It needs to dynamically generate all user provided names (class names, custom props, ...) and apply those correctly to JavaScript, HTML and CSS. Any module system for CSS would lack those properties. You would not be able to have two button styles each with `.button` in their own stylesheet file. - the HTML would still have `<button class="button">...` - either of the two files would still "win" and be applied last - you could still have some applied declarations from the earlier applied file. (5) CSS has effects. These are not side-effects, it's just CSS. Maybe this is my primary concern with this (and all similar proposals). CSS has a specific domain and works in a specific way. It might have sharp edges but it does work correctly and intuitively for its intended purpose. Transferring mental models and context from other domains (JavaScript) to CSS doesn't always work well. Making CSS into something else will likely make it worse, not better, even if such behavior is an opt-in. ------- It would be good to have an example use case where: - the issue isn't naming conflicts - the issue can't be solved by cascade layers - doesn't demand/assume total isolation -- GitHub Notification of comment by romainmenke Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10518#issuecomment-2202057354 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 2 July 2024 06:33:49 UTC