Support reconfigurable modules via "@forward ... with"
See original GitHub issueEdited by @nex3
The current plan is to add a with
clause to @forward
. This would work like the same clause in @use
, except that unconfigured variables or variables set with the !default
flag would still be configurable by the modules loading the module in which the @forward
appears. For example:
@forward "unopinionated" with (
$hue: 0 !default, // Can be overridden by upstream users.
$saturation: 50% // Cannot be overridden by upstream users.
);
I’ve been moving my Sass packages over to the module system, but I keep hitting a problem I can’t figure out. I usually have a central set of configuration variables that need to:
- be configurable by users
- be used by all the internal modules
But any time I make an internal file available to other files, I lose the ability to take user-configurations:
Error: This module was already loaded, so it can't be configured using "with".
I’ve tried adding duplicate !default
settings in each file that needs, but then I get:
Error: Module sass/_config.scss and the new module both forward a variable named $setting.
As far as I can tell, everything that uses a particular default variable has to live in the same file?
Is this how it’s meant to work? How would you recommend handling global package config shared among partials?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:23 (14 by maintainers)
Top GitHub Comments
You’ve found a bug! It looks like it’s even a bug in the spec: when you load a module with a config and that module forwards multiple modules, the config is passed as-is to all those modules, which will basically never do what you want. We need to be more sophisticated about how we handle that interaction.
The proposal has landed! I’m going to give it a couple weeks to accumulate feedback, and then move forward on implementation.