4 ms·
Why CSS Modules are so unpopular?
by efortis 2y ago
Why CSS Modules are so unpopular?
- recursive 2y agoIt's not standard yet. Behavior is implementation-defined and under-specified. A lot of people have used a thing like this[1], but this[2] is on a standards track. In the documentation for the first one, it describes a default "file scope", but really no definition of what a file is. It seems to be referring to a source file pre-build/bundle, but it really just doesn't say. That would belong in the documentation for some framework, not web platform stuff anyway. The idea of locally scoped styles is reasonably popular. Like vue single-file-components, and n+1 different implementations of "CSS modules". What it really needs though, is standardization. Things like [2] and the upcoming @scope will provide this. [1]: https://github.com/css-modules/css-modules/blob/master/docs/get-started.md https://github.com/css-modules/css-modules/blob/master/docs/... [2]: https://github.com/WICG/webcomponents/blob/gh-pages/proposals/css-modules-v1-explainer.md https://github.com/WICG/webcomponents/blob/gh-pages/proposal...
- Izkata 2y ago> In the documentation for the first one, it describes a default "file scope", but really no definition of what a file is. Probably because if you don't know what a file is, you have a lot more you need to learn first. It's a bare basic fundamental that goes way beyond CSS. But scope is true - CSS Modules like to pretend the CSS is specific to where it's used, and gloss over that some css attributes cascade to all children. @scope, and specifically the lower bound part of @scope, would fix this.
- recursive 2y agoYou missed my point about the files. Browsers generally don't see files in the way they're talking about. It's not a web standard. It's something for a particular bundle or build tool.