Since the end of last year SASS provides a proper module system. Sass source files can be included as a module by using @use instead of @import in sass/scss source files.
The SASS module system takes care of including the css from a sass source file only once in the output.
See the SASS Blog Post.
The problem that is tried to be solved by @carbon/import-once is solved by the sass compiler natively. This makes maintaining a custom solution unnecessary.
An official CLI tool is available to aid migrating an existing sass codebase.
SASS modules are supported by Dart-SASS since 1.23.0 and available via the NPM package sass
_From the SASS Blog:_
Problems with the use of _@import_
Hi @mister-what! 👋
Thanks so much for taking the time to write up this issue. There is so much thought/attention to it and we really appreciate it 🙏
We also totally agree. Sass modules are a great path forward. Unfortunately, we're not able to adopt them without a breaking change for adopters so we'll be trying to incorporate this in our next major release!
Gonna go ahead and close this one out. We're totally going to get to this in v11, but unfortunately, this isn't on our immediate roadmap 👀
Most helpful comment
Hi @mister-what! 👋
Thanks so much for taking the time to write up this issue. There is so much thought/attention to it and we really appreciate it 🙏
We also totally agree. Sass modules are a great path forward. Unfortunately, we're not able to adopt them without a breaking change for adopters so we'll be trying to incorporate this in our next major release!