Namespacing modules
See original GitHub issueRight now the only way to namespace a module is by nesting in a BEM format which gets messy real quick. I propose that a @namespace
syntax be introduced. With this we could have:
// _mod-module.scss
@namespace 'mod-module';
.foo{}
.bar{}
that interprets as this in CSS:
/* app.css */
.mod-module__foo{}
.mod-module__bar{}
Another option would be to leave the name spacing to when the module is being imported. This way we can specify modules we want to be namespaced from the manifest/index Sass file
// _mod-module.scss
.foo{}
.bar{}
@import 'mod-module', 'modModule';
this way the @namespace
syntax is not required so it produces:
/* app.css */
.modModule__foo{}
.modModule__bar{}
taking the name of the namespace as second argument to @import
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Documentation - Namespaces and Modules - TypeScript
Namespaces are a TypeScript-specific way to organize code. Namespaces are simply named JavaScript objects in the global namespace. This makes namespaces a very ......
Read more >Ruby Primer - Modules as Namespaces - RubyMonk
Namespacing is a way of bundling logically related objects together. Modules serve as a convenient tool for this. This allows classes or modules...
Read more >Namespacing With Modules · A Guide to Porting C ... - locka99
C++ namespaces allow you to group your functions, variables and classes into logical blocks and allow the compiler to disambiguate them from other...
Read more >Modules | Vuex
Namespacing #. By default, actions and mutations are still registered under the global namespace - this allows multiple modules to react to the ......
Read more >Module Files Are Namespaces - Learning Python by - O'Reilly
In Python-speak, modules are a namespace—a place where names are created. And names that live in a module are called its attributes. Technically,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree but there’s a solution to everything. Using ack, this would find every selectors you need for the nested syntax:
and for the new proposed syntax which is:
this should do the search:
As you’ve said it should be coupled with the module system but we have that better in Sass right now and not CSS. Hopefully we get houdini soon and all these can just be added extensions for CSS but Sass is the biggest hope for such a feature now. I hope this can be looked into more closely and reconsidered
To be honest, when working with BEM, I do not recommend any form of concatenation, even
&__foo {}
, since it makes search-n-finding of such selectors much harder, especially in large projects. So, whole idea with namespacing as part of Sass feature sounds very vague for me.At least for now I don’t see how Sass could handle this well, It should be part of CSS and closely coupled with imports (module system), then we won’t have obscurity and A LOT of potential edge cases introduced by Sass-only directive.